Skip to content

Commit

Permalink
Merge branch 'niconoe--fix-undefined-mi-on-interfaces'
Browse files Browse the repository at this point in the history
  • Loading branch information
Halleck45 committed Apr 10, 2017
2 parents 3d4627d + c849ab9 commit d7599aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
26 changes: 11 additions & 15 deletions src/Hal/Metric/Consolidated.php
Expand Up @@ -43,20 +43,17 @@ public function __construct(Metrics $metrics)
$project = [];
$nbInterfaces = 0;
foreach ($metrics->all() as $key => $item) {
if ($item instanceof ClassMetric) {
$classes[] = $item->all();;
}
if ($item instanceof InterfaceMetric) {
$classItem = get_class($item);
if (ClassMetric::class === $classItem) {
$classes[] = $item->all();
} elseif (InterfaceMetric::class === $classItem) {
$nbInterfaces++;
}
if ($item instanceof FunctionMetric) {
$functions[$key] = $item->all();;
}
if ($item instanceof FileMetric) {
$files[$key] = $item->all();;
}
if ($item instanceof ProjectMetric) {
$project[$key] = $item->all();;
} elseif (FunctionMetric::class === $classItem) {
$functions[$key] = $item->all();
} elseif (FileMetric::class === $classItem) {
$files[$key] = $item->all();
} elseif (ProjectMetric::class === $classItem) {
$project[$key] = $item->all();
}
}

Expand All @@ -82,7 +79,6 @@ public function __construct(Metrics $metrics)
'afferentCoupling' => [],
'efferentCoupling' => [],
'difficulty' => [],
'lcom' => [],
'mi' => [],
];

Expand All @@ -96,7 +92,7 @@ public function __construct(Metrics $metrics)
array_push($avg->$k, $item->get($k));
}
}
$sum->nbClasses = sizeof($classes) - $nbInterfaces;
$sum->nbClasses = count($classes);
$sum->nbInterfaces = $nbInterfaces;

foreach ($avg as &$a) {
Expand Down
2 changes: 1 addition & 1 deletion src/Hal/Metric/Metrics.php
Expand Up @@ -42,7 +42,7 @@ public function has($key)
}

/**
* @return array
* @return Metric[]
*/
public function all()
{
Expand Down

0 comments on commit d7599aa

Please sign in to comment.