abrain/einsatzverwaltung

View on GitHub
src/Import/Helper.php

Summary

Maintainability
D
1 day
Test Coverage
F
25%

File Helper.php has 307 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace abrain\Einsatzverwaltung\Import;

use abrain\Einsatzverwaltung\Data;
use abrain\Einsatzverwaltung\Exceptions\ImportException;
Severity: Minor
Found in src/Import/Helper.php - About 3 hrs to fix

    The class Helper has an overall complexity of 64 which is very high. The configured complexity threshold is 50.
    Open

    class Helper
    {
        /**
         * @var Utilities
         */
    Severity: Minor
    Found in src/Import/Helper.php by phpmd

    Method renderMatchForm has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function renderMatchForm($source, $args)
        {
            $defaults = array(
                'mapping' => array(),
                'next_action' => null,
    Severity: Minor
    Found in src/Import/Helper.php - About 1 hr to fix

      Function mapEntryToInsertArgs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function mapEntryToInsertArgs($mapping, $sourceEntry, &$insertArgs)
          {
              foreach ($mapping as $sourceField => $ownField) {
                  if (empty($ownField) || !is_string($ownField)) {
                      $this->utilities->printError("Feld '$ownField' ung&uuml;ltig");
      Severity: Minor
      Found in src/Import/Helper.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method prepareArgsForInsertPost has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function prepareArgsForInsertPost(&$insertArgs, $dateTimeFormat, $postStatus, $alarmzeit)
          {
              // Datum des Einsatzes prüfen
              if (false === $alarmzeit) {
                  throw new ImportPreparationException(sprintf(
      Severity: Minor
      Found in src/Import/Helper.php - About 1 hr to fix

        Method dropdownEigeneFelder has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function dropdownEigeneFelder($args)
            {
                $defaults = array(
                    'name' => null,
                    'selected' => '-',
        Severity: Minor
        Found in src/Import/Helper.php - About 1 hr to fix

          Function renderMatchForm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function renderMatchForm($source, $args)
              {
                  $defaults = array(
                      'mapping' => array(),
                      'next_action' => null,
          Severity: Minor
          Found in src/Import/Helper.php - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method validateMapping has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function validateMapping($mapping, $source)
              {
                  $valid = true;
          
                  // Pflichtfelder prüfen
          Severity: Minor
          Found in src/Import/Helper.php - About 1 hr to fix

            Function prepareArgsForInsertPost has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function prepareArgsForInsertPost(&$insertArgs, $dateTimeFormat, $postStatus, $alarmzeit)
                {
                    // Datum des Einsatzes prüfen
                    if (false === $alarmzeit) {
                        throw new ImportPreparationException(sprintf(
            Severity: Minor
            Found in src/Import/Helper.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function validateMapping has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function validateMapping($mapping, $source)
                {
                    $valid = true;
            
                    // Pflichtfelder prüfen
            Severity: Minor
            Found in src/Import/Helper.php - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function runImport has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function runImport($preparedInsertArgs, $source, $yearsAffected, $importStatus)
                {
                    // Für die Dauer des Imports sollen die laufenden Nummern nicht aktuell gehalten werden, da dies die Performance
                    // stark beeinträchtigt
                    if ($source->isPublishReports()) {
            Severity: Minor
            Found in src/Import/Helper.php - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            There are no issues that match your filters.

            Category
            Status