Пример #1
0
 public function __construct($name, $xmlFile)
 {
     $doc = new \DOMDocument();
     $doc->load($xmlFile);
     /** @var \DOMElement $root */
     $root = $doc->childNodes->item(0);
     parent::__construct($name, ['ahh' => $root->getAttribute('ahh'), 'andc' => $root->getAttribute('andc'), 'calls' => $root->getAttribute('calls'), 'ccn' => $root->getAttribute('ccn'), 'ccn2' => $root->getAttribute('ccn2'), 'cloc' => $root->getAttribute('cloc'), 'clsa' => $root->getAttribute('clsa'), 'clsc' => $root->getAttribute('clsc'), 'eloc' => $root->getAttribute('eloc'), 'fanout' => $root->getAttribute('fanout'), 'leafs' => $root->getAttribute('leafs'), 'lloc' => $root->getAttribute('lloc'), 'loc' => $root->getAttribute('loc'), 'maxDIT' => $root->getAttribute('maxDIT'), 'ncloc' => $root->getAttribute('ncloc'), 'roots' => $root->getAttribute('roots')]);
     foreach ($root->childNodes as $node) {
         if ($node->nodeName == 'package') {
             $this->addChild($this->parsePackage($node));
         }
     }
 }
Пример #2
0
/**
 * @param AbstractMetrics $root
 * @param int             $level
 */
function listMetrics($root, $level = 0)
{
    $loc = $root->get('loc', 'sum');
    $len = 32;
    $name = str_repeat('  ', $level) . $root;
    if (strlen($name) > $len) {
        $name = substr($name, 0, $len - 1) . '…';
    }
    if ($loc == 0) {
        printf("%-{$len}s  MI:    --  CC: --  LoC:% 4d  Time:    --   \n", $name, $loc);
        return;
    }
    printf("%-{$len}s  MI:% 6.0f  CC:% 3d  LoC:% 4d  Time:%10s\n", $name, $root->maintainabilityIndex(), $root->get('ccn', 'max'), $loc, time($root->get('ht', 'sum')));
    foreach ($root->getChildren() as $child) {
        listMetrics($child, $level + 1);
    }
}
Пример #3
0
 public function __construct($name, $type, $data = [])
 {
     parent::__construct($name, $data);
     $this->type = $type;
 }