Exemplo n.º 1
0
function printUsage($arg)
{
    echo 'Usage: php ' . basename($arg) . ' MetricsXml' . PHP_EOL;
    echo '    MetricsXml    - Metrics in PDepend xml format' . PHP_EOL;
    echo PHP_EOL;
    die("");
}
if (!isset($argv["1"]) || !$argv["1"]) {
    printUsage($argv["0"]);
}
$sMetricsXml = $argv["1"];
try {
    $oMetrics = new Metrics($sMetricsXml);
    if ($oMetrics->isExistingMetricsFile()) {
        $oMetrics->read();
        echo "Total Avg ccn\t= " . round($oMetrics->getTotalAverageCCN(), 3) . " (max: " . $oMetrics->getMaxCCN() . ")" . PHP_EOL;
        echo "Total Avg crap\t= " . round($oMetrics->getTotalAverageCrapIndex(), 3) . " (max: " . $oMetrics->getMaxCrapIndex() . ")" . PHP_EOL;
        echo "Total Avg NPath\t= " . round($oMetrics->getTotalAverageNPath(), 3) . " (max: " . $oMetrics->getMaxNPath() . ")" . PHP_EOL;
        echo "Total LLOC\t= " . $oMetrics->getTotalLLOC() . " (max: " . $oMetrics->getMaxLLOC() . ")" . PHP_EOL . PHP_EOL;
        $aStats = $oMetrics->getClassesStats();
        foreach ($aStats as $sClass => $aClass) {
            echo "Total for {$sClass}" . PHP_EOL;
            echo "\tAvg ccn \t= " . round($aClass['stat']['cnn'], 3) . " (max: " . $aClass['max']['cnn'] . ")" . PHP_EOL;
            echo "\tAvg crap\t= " . round($aClass['stat']['crap'], 3) . " (max: " . $aClass['max']['crap'] . ")" . PHP_EOL;
            echo "\tAvg npath\t= " . round($aClass['stat']['npath'], 3) . " (max: " . $aClass['max']['npath'] . ")" . PHP_EOL;
            echo "\tLLOC \t\t= " . $aClass['sum']['locExecutable'] . PHP_EOL . PHP_EOL;
        }
    } else {
        echo "\n\nMetrics file: " . $sMetricsXml . " not exist, please select existing file!\n\n";
    }
} catch (Exception $oE) {