codeformunich/Muenchen-Transparent

View on GitHub
protected/components/OParl10Object.php

Summary

Maintainability
D
1 day
Test Coverage

File OParl10Object.php has 364 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Enthält die Funktionen zum Erzeugen alle OParl-Objekte. Der Zugriff auf die Objekte wird durch die get()-Methode
 * abstrahiert.
Severity: Minor
Found in protected/components/OParl10Object.php - About 4 hrs to fix

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

    class OParl10Object {
        const TYPE_AGENDAITEM      = 'https://schema.oparl.org/1.0/AgendaItem';
        const TYPE_BODY            = 'https://schema.oparl.org/1.0/Body';
        const TYPE_CONSULTATION    = 'https://schema.oparl.org/1.0/Consultation';
        const TYPE_FILE            = 'https://schema.oparl.org/1.0/File';

    Method person has 50 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

        private static function person($id) {
            /** @var StadtraetIn $stadtraetin */
            $stadtraetin = StadtraetIn::model()->findByPk($id);
    
            $body = 0; // fallback
    Severity: Minor
    Found in protected/components/OParl10Object.php - About 1 hr to fix

      Method legislativeterm has 39 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

          private static function legislativeterm($id) {
              $data = [
                  [
                      'type'      => self::TYPE_LEGISLATIVETERM,
                      'name'      => 'Unbekannt',
      Severity: Minor
      Found in protected/components/OParl10Object.php - About 1 hr to fix

        Method body has 35 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

            private static function body($id) {
                /** @var Bezirksausschuss $ba */
                $ba = Bezirksausschuss::model()->findByPk($id);
        
                if ($id == 0) {
        Severity: Minor
        Found in protected/components/OParl10Object.php - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                  else if ($type == 'location'       ) return self::location($id, $subtype);
          Severity: Major
          Found in protected/components/OParl10Object.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    else if ($type == 'agendaitem'     ) return self::agendaitem($id);
            Severity: Major
            Found in protected/components/OParl10Object.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      else if ($type == 'membership'     ) return self::membership($id, $subtype);
              Severity: Major
              Found in protected/components/OParl10Object.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return ['error' => 'No such object type ' . $type];
                Severity: Major
                Found in protected/components/OParl10Object.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          else if ($type == 'system'         ) return self::system();
                  Severity: Major
                  Found in protected/components/OParl10Object.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            else if ($type == 'organization'   ) return self::organization($id, $subtype);
                    Severity: Major
                    Found in protected/components/OParl10Object.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              else if ($type == 'person'         ) return self::person($id);
                      Severity: Major
                      Found in protected/components/OParl10Object.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                else if ($type == 'consultation'   ) return self::consultation($id);
                        Severity: Major
                        Found in protected/components/OParl10Object.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  else if ($type == 'paper'          ) return self::paper($id);
                          Severity: Major
                          Found in protected/components/OParl10Object.php - About 30 mins to fix

                            The method person() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                            Open

                                private static function person($id) {
                                    /** @var StadtraetIn $stadtraetin */
                                    $stadtraetin = StadtraetIn::model()->findByPk($id);
                            
                                    $body = 0; // fallback

                            CyclomaticComplexity

                            Since: 0.1

                            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                            Example

                            // Cyclomatic Complexity = 11
                            class Foo {
                            1   public function example() {
                            2       if ($a == $b) {
                            3           if ($a1 == $b1) {
                                            fiddle();
                            4           } elseif ($a2 == $b2) {
                                            fiddle();
                                        } else {
                                            fiddle();
                                        }
                            5       } elseif ($c == $d) {
                            6           while ($c == $d) {
                                            fiddle();
                                        }
                            7        } elseif ($e == $f) {
                            8           for ($n = 0; $n < $h; $n++) {
                                            fiddle();
                                        }
                                    } else {
                                        switch ($z) {
                            9               case 1:
                                                fiddle();
                                                break;
                            10              case 2:
                                                fiddle();
                                                break;
                            11              case 3:
                                                fiddle();
                                                break;
                                            default:
                                                fiddle();
                                                break;
                                        }
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                            The method get() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                            Open

                                public static function get($type, $id, $subtype = null) {
                                    if      ($type == 'body'           ) return self::body($id);
                                    else if ($type == 'file'           ) return self::file($id);
                                    else if ($type == 'legislativeterm') return self::legislativeterm($id);
                                    else if ($type == 'meeting'        ) return self::meeting($id);

                            CyclomaticComplexity

                            Since: 0.1

                            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                            Example

                            // Cyclomatic Complexity = 11
                            class Foo {
                            1   public function example() {
                            2       if ($a == $b) {
                            3           if ($a1 == $b1) {
                                            fiddle();
                            4           } elseif ($a2 == $b2) {
                                            fiddle();
                                        } else {
                                            fiddle();
                                        }
                            5       } elseif ($c == $d) {
                            6           while ($c == $d) {
                                            fiddle();
                                        }
                            7        } elseif ($e == $f) {
                            8           for ($n = 0; $n < $h; $n++) {
                                            fiddle();
                                        }
                                    } else {
                                        switch ($z) {
                            9               case 1:
                                                fiddle();
                                                break;
                            10              case 2:
                                                fiddle();
                                                break;
                            11              case 3:
                                                fiddle();
                                                break;
                                            default:
                                                fiddle();
                                                break;
                                        }
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                            The class OParl10Object has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
                            Open

                            class OParl10Object {
                                const TYPE_AGENDAITEM      = 'https://schema.oparl.org/1.0/AgendaItem';
                                const TYPE_BODY            = 'https://schema.oparl.org/1.0/Body';
                                const TYPE_CONSULTATION    = 'https://schema.oparl.org/1.0/Consultation';
                                const TYPE_FILE            = 'https://schema.oparl.org/1.0/File';

                            CouplingBetweenObjects

                            Since: 1.1.0

                            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                            Example

                            class Foo {
                                /**
                                 * @var \foo\bar\X
                                 */
                                private $x = null;
                            
                                /**
                                 * @var \foo\bar\Y
                                 */
                                private $y = null;
                            
                                /**
                                 * @var \foo\bar\Z
                                 */
                                private $z = null;
                            
                                public function setFoo(\Foo $foo) {}
                                public function setBar(\Bar $bar) {}
                                public function setBaz(\Baz $baz) {}
                            
                                /**
                                 * @return \SplObjectStorage
                                 * @throws \OutOfRangeException
                                 * @throws \InvalidArgumentException
                                 * @throws \ErrorException
                                 */
                                public function process(\Iterator $it) {}
                            
                                // ...
                            }

                            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

                            FIXME found
                            Open

                                    // FIXME: Externe Liste mit Meetings

                            TODO found
                            Open

                                    // TODO

                            There are no issues that match your filters.

                            Category
                            Status