CRITICAL
Rule Definition
A class with an excessive number of children is an indicator of an unbalanced class hierarchy. You should consider refactoring this class hierarchy.
Remediation
Review the architecture of the application.
Violation Code Sample
<?php
class ClassWithTooManyChildren
{
public $var1 = myConstant1;
public $var2 = myConstant2;
public $var3 = myConstant3;
public $var4 = myConstant4;
public $var5 = myConstant5;
public $var6 = myConstant6;
public $var7 = myConstant7;
public $var8 = myConstant8;
public $var9 = myConstant9;
public $var10 = myConstant10;
public $var11 = myConstant11;
public $var12 = myConstant12;
public $var13 = myConstant13;
public $var14 = myConstant14;
public $var15 = myConstant15;
public $var16 = myConstant16;
public function displayVar1() {
echo $this->var1;
}
public function displayVar2() {
echo $this->var2;
}
public function displayVar3() {
echo $this->var3;
}
public function displayVar4() {
echo $this->var4;
}
public function displayVar5() {
echo $this->var5;
}
public function displayVar6() {
echo $this->var6;
}
public function displayVar7() {
echo $this->var7;
}
public function displayVar8() {
echo $this->var8;
}
public function displayVar9() {
echo $this->var9;
}
public function displayVar10() {
echo $this->var10;
}
public function displayVar11() {
echo $this->var11;
}
public function displayVar12() {
echo $this->var12;
}
public function displayVar13() {
echo $this->var13;
}
public function displayVar14() {
echo $this->var14;
}
public function displayVar15() {
echo $this->var15;
}
}
?>
Reference
PHPMD - http://phpmd.org/rules/design.html#numberofchildren
Related Technologies
Technical Criterion
CWE-1086 - Class with Excessive Number of Child Classes
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.