@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | public function calculate(Metrics $metrics) |
14 | 14 | { |
15 | - $classes = array_filter($metrics->all(), function (Metric $metric) { |
|
15 | + $classes = array_filter($metrics->all(), function(Metric $metric) { |
|
16 | 16 | return $metric instanceof ClassMetric || $metric instanceof InterfaceMetric; |
17 | 17 | }); |
18 | 18 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | private function increaseDependencies(Metric $class, Metrics $metrics) |
29 | 29 | { |
30 | - if (! $class->has('package') || ! $class->has('externals')) { |
|
30 | + if (!$class->has('package') || !$class->has('externals')) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | $incomingPackage = $metrics->get($class->get('package')); /* @var $incomingPackage PackageMetric */ |
@@ -56,6 +56,6 @@ discard block |
||
56 | 56 | } |
57 | 57 | $parts = explode('\\', $className); |
58 | 58 | array_pop($parts); |
59 | - return implode('\\', $parts) . '\\'; |
|
59 | + return implode('\\', $parts).'\\'; |
|
60 | 60 | } |
61 | 61 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public function calculate(Metrics $metrics) |
11 | 11 | { |
12 | 12 | /* @var $packages PackageMetric[] */ |
13 | - $packages = array_filter($metrics->all(), function ($metric) { |
|
13 | + $packages = array_filter($metrics->all(), function($metric) { |
|
14 | 14 | return $metric instanceof PackageMetric; |
15 | 15 | }); |
16 | 16 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | } |
29 | 29 | // Set depending instabilities |
30 | 30 | foreach ($packages as $eachPackage) { |
31 | - $dependentInstabilities = array_map(function ($packageName) use ($instabilitiesByPackage) { |
|
31 | + $dependentInstabilities = array_map(function($packageName) use ($instabilitiesByPackage) { |
|
32 | 32 | return isset($instabilitiesByPackage[$packageName]) ? $instabilitiesByPackage[$packageName] : null; |
33 | 33 | }, $eachPackage->getOutgoingPackageDependencies()); |
34 | 34 | $dependentInstabilities = array_combine( |
@@ -17,7 +17,6 @@ |
||
17 | 17 | public static function getName(Node $node) |
18 | 18 | { |
19 | 19 | return ($node instanceof Node\Stmt\Class_ && $node->isAnonymous()) ? |
20 | - 'anonymous@' . spl_object_hash($node) : |
|
21 | - $node->namespacedName->toString(); |
|
20 | + 'anonymous@'.spl_object_hash($node) : $node->namespacedName->toString(); |
|
22 | 21 | } |
23 | 22 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | return; |
45 | 45 | } |
46 | 46 | if (!file_exists(dirname($logFile)) || !is_writable(dirname($logFile))) { |
47 | - throw new \RuntimeException('You don\'t have permissions to write CSV report in ' . $logFile); |
|
47 | + throw new \RuntimeException('You don\'t have permissions to write CSV report in '.$logFile); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $availables = (new Registry())->allForStructures(); |
@@ -42,7 +42,7 @@ |
||
42 | 42 | return; |
43 | 43 | } |
44 | 44 | if (!file_exists(dirname($logFile)) || !is_writable(dirname($logFile))) { |
45 | - throw new \RuntimeException('You don\'t have permissions to write JSON report in ' . $logFile); |
|
45 | + throw new \RuntimeException('You don\'t have permissions to write JSON report in '.$logFile); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | file_put_contents($logFile, json_encode($metrics, JSON_PRETTY_PRINT)); |
@@ -1,9 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Hal\Metric\Class_\Component; |
3 | 3 | |
4 | -use Hal\Metric\FunctionMetric; |
|
5 | 4 | use Hal\Metric\Metrics; |
6 | -use Hoa\Ruler\Model\Bag\Scalar; |
|
7 | 5 | use PhpParser\Node; |
8 | 6 | use PhpParser\Node\Stmt; |
9 | 7 | use PhpParser\NodeVisitorAbstract; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | public function leaveNode(Node $node) |
48 | 48 | { |
49 | 49 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Trait_) { |
50 | - $name = (string)(isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node)); |
|
50 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node)); |
|
51 | 51 | $classOrFunction = $this->metrics->get($name); |
52 | 52 | |
53 | 53 | if (null === $lloc = $classOrFunction->get('lloc')) { |
@@ -78,7 +78,7 @@ |
||
78 | 78 | $metrics = new Metrics(); |
79 | 79 | |
80 | 80 | // traverse all |
81 | - $whenToStop = function () { |
|
81 | + $whenToStop = function() { |
|
82 | 82 | return true; |
83 | 83 | }; |
84 | 84 |
@@ -27,7 +27,7 @@ |
||
27 | 27 | */ |
28 | 28 | public function addEdge(Node $from, Node $to) |
29 | 29 | { |
30 | - $key = $from->getUniqueId() . '->' . $to->getUniqueId(); |
|
30 | + $key = $from->getUniqueId().'->'.$to->getUniqueId(); |
|
31 | 31 | |
32 | 32 | if (isset($this->edgesMap[$key])) { |
33 | 33 | return $this; |
@@ -18,10 +18,10 @@ |
||
18 | 18 | |
19 | 19 | public function apply(Metric $metric) |
20 | 20 | { |
21 | - if (! $metric instanceof PackageMetric) { |
|
21 | + if (!$metric instanceof PackageMetric) { |
|
22 | 22 | return; |
23 | 23 | } |
24 | - if (abs($metric->getDistance()) > sqrt(2)/4) { |
|
24 | + if (abs($metric->getDistance()) > sqrt(2) / 4) { |
|
25 | 25 | $this->metric = $metric; |
26 | 26 | $metric->get('violations')->add($this); |
27 | 27 | } |