abrain/einsatzverwaltung

View on GitHub
src/Import/Helper.php

Summary

Maintainability
D
1 day
Test Coverage
F
0%

The class Helper has an overall complexity of 65 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

Since: PHPMD 0.2.5

The Weighted Method Count (WMC) of a class is a good indicator of how much time and effort is required to modify and maintain this class. The WMC metric is defined as the sum of complexities of all methods declared in a class. A large number of methods also means that this class has a greater potential impact on derived classes.

Example:

class Foo {
      public function bar() {
          if ($a == $b)  {
              if ($a1 == $b1) {
                  fiddle();
              } elseif ($a2 == $b2) {
                  fiddle();
              } else {
              }
          }
      }
      public function baz() {
          if ($a == $b) {
              if ($a1 == $b1) {
                  fiddle();
              } elseif ($a2 == $b2) {
                  fiddle();
              } else {
              }
          }
      }
      // Several other complex methods
  }

Source: http://phpmd.org/rules/codesize.txt

File Helper.php has 305 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

    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

            Line exceeds 120 characters; contains 188 characters
            Open

                        throw new ImportPreparationException('Die Importquelle lieferte keine Ergebnisse. Entweder sind dort keine Eins&auml;tze gespeichert oder es gab ein Problem bei der Abfrage.');
            Severity: Minor
            Found in src/Import/Helper.php by phpcodesniffer

            Line exceeds 120 characters; contains 138 characters
            Open

                        $this->utilities->printInfo('Einsatznummern können nur importiert werden, wenn die automatische Verwaltung deaktiviert ist.');
            Severity: Minor
            Found in src/Import/Helper.php by phpcodesniffer

            There are no issues that match your filters.

            Category
            Status