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.
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';
- Exclude checks
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
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',
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) {
Avoid too many return
statements within this method. Open
else if ($type == 'location' ) return self::location($id, $subtype);
Avoid too many return
statements within this method. Open
else if ($type == 'agendaitem' ) return self::agendaitem($id);
Avoid too many return
statements within this method. Open
else if ($type == 'membership' ) return self::membership($id, $subtype);
Avoid too many return
statements within this method. Open
return ['error' => 'No such object type ' . $type];
Avoid too many return
statements within this method. Open
else if ($type == 'system' ) return self::system();
Avoid too many return
statements within this method. Open
else if ($type == 'organization' ) return self::organization($id, $subtype);
Avoid too many return
statements within this method. Open
else if ($type == 'person' ) return self::person($id);
Avoid too many return
statements within this method. Open
else if ($type == 'consultation' ) return self::consultation($id);
Avoid too many return
statements within this method. Open
else if ($type == 'paper' ) return self::paper($id);
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
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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';
- Read upRead up
- Exclude checks
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
- Exclude checks
TODO found Open
// TODO
- Exclude checks