diff --git a/src/Hal/Metric/Consolidated.php b/src/Hal/Metric/Consolidated.php index 3dc7fc34..70235e04 100644 --- a/src/Hal/Metric/Consolidated.php +++ b/src/Hal/Metric/Consolidated.php @@ -103,6 +103,7 @@ public function __construct(Metrics $metrics) } $sum->nbClasses = count($classes); $sum->nbInterfaces = $nbInterfaces; + $sum->nbPackages = count($packages); foreach ($avg as &$a) { if (sizeof($a) > 0) { @@ -112,6 +113,29 @@ public function __construct(Metrics $metrics) } } + $avg->distance = 0; + $avg->incomingCDep = 0; + $avg->incomingPDep = 0; + $avg->outgoingCDep = 0; + $avg->outgoingPDep = 0; + $avg->classesPerPackage = 0; + foreach (array_keys($packages) as $eachName) { + /* @var $eachPackage PackageMetric */ + $eachPackage = $metrics->get($eachName); + $avg->distance += $eachPackage->getDistance(); + $avg->incomingCDep += count($eachPackage->getIncomingClassDependencies()); + $avg->incomingPDep += count($eachPackage->getIncomingPackageDependencies()); + $avg->outgoingCDep += count($eachPackage->getOutgoingClassDependencies()); + $avg->outgoingPDep += count($eachPackage->getOutgoingPackageDependencies()); + $avg->classesPerPackage += count($eachPackage->getClasses()); + } + $avg->distance = round($avg->distance / count($packages), 2); + $avg->incomingCDep = round($avg->incomingCDep / count($packages), 2); + $avg->incomingPDep = round($avg->incomingPDep / count($packages), 2); + $avg->outgoingCDep = round($avg->outgoingCDep / count($packages), 2); + $avg->outgoingPDep = round($avg->outgoingPDep / count($packages), 2); + $avg->classesPerPackage = round($avg->classesPerPackage / count($packages), 2); + // sums of violations $violations = [ 'total' => 0, diff --git a/src/Hal/Report/Cli/Reporter.php b/src/Hal/Report/Cli/Reporter.php index 98a06eab..ddf7dca6 100644 --- a/src/Hal/Report/Cli/Reporter.php +++ b/src/Hal/Report/Cli/Reporter.php @@ -75,6 +75,15 @@ public function generate(Metrics $metrics) Average efferent coupling {$avg->efferentCoupling} Average instability {$avg->instability} Depth of Inheritance Tree {$metrics->get('tree')->get('depthOfInheritanceTree')} + +Package + Packages {$sum->nbPackages} + Average classes per package {$avg->classesPerPackage} + Average distance {$avg->distance} + Average incoming class dependencies {$avg->incomingCDep} + Average outgoing class dependencies {$avg->outgoingCDep} + Average incoming package dependencies {$avg->incomingPDep} + Average outgoing package dependencies {$avg->outgoingPDep} Complexity Average Cyclomatic complexity by class {$avg->ccn}