| Conditions | 5 |
| Paths | 6 |
| Total Lines | 34 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function calculate(Metrics $metrics) |
||
| 11 | { |
||
| 12 | /* @var $packages PackageMetric[] */ |
||
| 13 | $packages = array_filter($metrics->all(), function ($metric) { |
||
| 14 | return $metric instanceof PackageMetric; |
||
| 15 | }); |
||
| 16 | |||
| 17 | // Calculate instability |
||
| 18 | $instabilitiesByPackage = []; |
||
| 19 | foreach ($packages as $eachPackage) { |
||
| 20 | $afferentCoupling = count($eachPackage->getIncomingClassDependencies()); |
||
| 21 | $efferentCoupling = count($eachPackage->getOutgoingClassDependencies()); |
||
| 22 | if ($afferentCoupling + $efferentCoupling !== 0) { |
||
| 23 | $eachPackage->setInstability( |
||
| 24 | $efferentCoupling / ($afferentCoupling + $efferentCoupling) |
||
| 25 | ); |
||
| 26 | $instabilitiesByPackage[$eachPackage->getName()] = $eachPackage->getInstability(); |
||
|
|
|||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | // Set depending instabilities |
||
| 31 | foreach ($packages as $eachPackage) { |
||
| 32 | $dependentInstabilities = array_map(function ($packageName) use ($instabilitiesByPackage) { |
||
| 33 | return isset($instabilitiesByPackage[$packageName]) ? $instabilitiesByPackage[$packageName] : null; |
||
| 34 | }, $eachPackage->getOutgoingPackageDependencies()); |
||
| 35 | $dependentInstabilities = array_combine( |
||
| 36 | $eachPackage->getOutgoingPackageDependencies(), |
||
| 37 | $dependentInstabilities |
||
| 38 | ); |
||
| 39 | $dependentInstabilities = array_filter($dependentInstabilities); |
||
| 40 | $eachPackage->setDependentInstabilities($dependentInstabilities); |
||
| 41 | } |
||
| 42 | |||
| 43 | } |
||
| 44 | } |
||
| 45 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.