Completed
Pull Request — master (#376)
by Michael
01:33
created
src/Hal/Metric/Package/PackageDependencies.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
56 56
         }
57 57
         $parts = explode('\\', $className);
58 58
         array_pop($parts);
59
-        return implode('\\', $parts) . '\\';
59
+        return implode('\\', $parts).'\\';
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
src/Hal/Metric/Package/PackageInstability.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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(
Please login to merge, or discard this patch.
src/Hal/Metric/Helper/MetricClassNameGenerator.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Hal/Report/Csv/Reporter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/Hal/Report/Json/Reporter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
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));
Please login to merge, or discard this patch.
src/Hal/Metric/System/Packages/Composer/Composer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
             $package = $packagist->get($requirement);
47 47
 
48
-            $packages[$requirement] = (object)array(
48
+            $packages[$requirement] = (object) array(
49 49
                 'name' => $requirement,
50 50
                 'required' => $version,
51 51
                 'installed' => isset($rawInstalled[$requirement]) ? $rawInstalled[$requirement] : null,
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
             if (!\preg_match('/composer(-dist)?\.json/', $filename)) {
77 77
                 continue;
78 78
             }
79
-            $composerJson = (object)\json_decode(\file_get_contents($filename));
79
+            $composerJson = (object) \json_decode(\file_get_contents($filename));
80 80
 
81 81
             if (!isset($composerJson->require)) {
82 82
                 continue;
83 83
             }
84 84
 
85
-            $rawRequirements[] = (array)$composerJson->require;
85
+            $rawRequirements[] = (array) $composerJson->require;
86 86
         }
87 87
 
88 88
         return \call_user_func_array('array_merge', $rawRequirements);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             if (false === \strpos($filename, 'composer.lock')) {
107 107
                 continue;
108 108
             }
109
-            $composerLockJson = (object)\json_decode(\file_get_contents($filename));
109
+            $composerLockJson = (object) \json_decode(\file_get_contents($filename));
110 110
 
111 111
             if (!isset($composerLockJson->packages)) {
112 112
                 continue;
Please login to merge, or discard this patch.
src/Hal/Report/Html/template/index.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php require __DIR__ . '/_header.php'; ?>
1
+<?php require __DIR__.'/_header.php'; ?>
2 2
     <div class="row">
3 3
         <div class="column">
4 4
             <div class="bloc bloc-number">
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                             <tbody id="contentClassRank" class="clusterize-content">
96 96
                             <?php
97 97
                             $classesS = $classes;
98
-                            usort($classesS, function ($a, $b) {
98
+                            usort($classesS, function($a, $b) {
99 99
                                 return strcmp($b['pageRank'], $a['pageRank']);
100 100
                             });
101 101
                             //$classesS = array_slice($classesS, 0, 10);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                             <tbody id="contentPackages" class="clusterize-content">
138 138
                             <?php
139 139
                             $packages = isset($project['composer'], $project['composer']['packages']) ? $project['composer']['packages'] : [];
140
-                            usort($packages, function ($a, $b) {
140
+                            usort($packages, function($a, $b) {
141 141
                                 return strcmp($a->name, $b->name);
142 142
                             });
143 143
                             foreach ($packages as $package) { ?>
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
                                     <td><?php echo $package->required; ?></td>
147 147
                                     <?php if (0 !== count($packagesInstalled)) {?><td><?php echo $package->installed; ?></td><?php } ?>
148 148
                                     <td><?php echo $package->latest; ?></td>
149
-                                    <td><?php foreach($package->license as $license) { ?>
150
-                                            <a target="_blank" href="https://spdx.org/licenses/<?php echo $license;?>.html"><?php echo $license;?></a>
149
+                                    <td><?php foreach ($package->license as $license) { ?>
150
+                                            <a target="_blank" href="https://spdx.org/licenses/<?php echo $license; ?>.html"><?php echo $license; ?></a>
151 151
                                         <?php } ?>
152 152
                                     </td>
153 153
                                 </tr>
154 154
                             <?php } ?>
155 155
                             </tbody>
156 156
                         </table>
157
-                        <?php if(0 === count($packages)) { ?>
157
+                        <?php if (0 === count($packages)) { ?>
158 158
                             <div>No composer.json file found</div>
159 159
                         <?php } ?>
160
-                        <?php if(0 === count($packagesInstalled)) { ?>
160
+                        <?php if (0 === count($packagesInstalled)) { ?>
161 161
                             <div>No composer.lock file found</div>
162 162
                         <?php } ?>
163 163
                     </div>
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         <div class="column">
169 169
             <div class="bloc bloc-number">
170 170
                 <div class="label">Licences of Composer dependencies</div>
171
-                <?php if(0 === sizeof($packages)) { ?>
171
+                <?php if (0 === sizeof($packages)) { ?>
172 172
                     <div>No composer.json file found</div>
173 173
                 <?php } ?>
174 174
                 <div id="svg-licenses"></div>
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
                     }
208 208
                 }
209 209
                 ?>
210
-                chartLicenses(<?php echo json_encode(array_values($json));?>);
210
+                chartLicenses(<?php echo json_encode(array_values($json)); ?>);
211 211
             }
212 212
         };
213 213
     </script>
214 214
 
215
-<?php require __DIR__ . '/_footer.php'; ?>
215
+<?php require __DIR__.'/_footer.php'; ?>
Please login to merge, or discard this patch.
src/Hal/Report/Html/Reporter.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
         $consolidated = new Consolidated($metrics);
45 45
 
46 46
         // history of builds
47
-        $today = (object)[
47
+        $today = (object) [
48 48
             'avg' => $consolidated->getAvg(),
49 49
             'sum' => $consolidated->getSum()
50 50
         ];
51
-        $files = glob($logDir . '/js/history-*.json');
51
+        $files = glob($logDir.'/js/history-*.json');
52 52
         $next = sizeof($files) + 1;
53 53
         $history = [];
54 54
         natsort($files);
@@ -57,39 +57,39 @@  discard block
 block discarded – undo
57 57
         }
58 58
 
59 59
         // copy sources
60
-        if(!file_exists($logDir . '/js')) {
60
+        if (!file_exists($logDir.'/js')) {
61 61
             mkdir($logDir.'/js', 0755, true);
62 62
         }
63
-        if(!file_exists($logDir . '/css')) {
63
+        if (!file_exists($logDir.'/css')) {
64 64
             mkdir($logDir.'/css', 0755, true);
65 65
         }
66
-        if(!file_exists($logDir . '/images')) {
66
+        if (!file_exists($logDir.'/images')) {
67 67
             mkdir($logDir.'/images', 0755, true);
68 68
         }
69
-        if(!file_exists($logDir . '/fonts')) {
69
+        if (!file_exists($logDir.'/fonts')) {
70 70
             mkdir($logDir.'/fonts', 0755, true);
71 71
         }
72
-        recurse_copy(__DIR__ . '/template/js', $logDir . '/js');
73
-        recurse_copy(__DIR__ . '/template/css', $logDir . '/css');
74
-        recurse_copy(__DIR__ . '/template/images', $logDir . '/images');
75
-        recurse_copy(__DIR__ . '/template/fonts', $logDir . '/fonts');
72
+        recurse_copy(__DIR__.'/template/js', $logDir.'/js');
73
+        recurse_copy(__DIR__.'/template/css', $logDir.'/css');
74
+        recurse_copy(__DIR__.'/template/images', $logDir.'/images');
75
+        recurse_copy(__DIR__.'/template/fonts', $logDir.'/fonts');
76 76
 
77 77
         // render dynamic pages
78
-        $this->renderPage(__DIR__ . '/template/index.php', $logDir . '/index.html', $consolidated, $history);
79
-        $this->renderPage(__DIR__ . '/template/loc.php', $logDir . '/loc.html', $consolidated, $history);
80
-        $this->renderPage(__DIR__ . '/template/relations.php', $logDir . '/relations.html', $consolidated, $history);
81
-        $this->renderPage(__DIR__ . '/template/coupling.php', $logDir . '/coupling.html', $consolidated, $history);
82
-        $this->renderPage(__DIR__ . '/template/all.php', $logDir . '/all.html', $consolidated, $history);
83
-        $this->renderPage(__DIR__ . '/template/oop.php', $logDir . '/oop.html', $consolidated, $history);
84
-        $this->renderPage(__DIR__ . '/template/complexity.php', $logDir . '/complexity.html', $consolidated, $history);
85
-        $this->renderPage(__DIR__ . '/template/panel.php', $logDir . '/panel.html', $consolidated, $history);
86
-        $this->renderPage(__DIR__ . '/template/violations.php', $logDir . '/violations.html', $consolidated, $history);
87
-        $this->renderPage(__DIR__ . '/template/packages.php', $logDir . '/packages.html', $consolidated, $history);
88
-        $this->renderPage(__DIR__ . '/template/package_relations.php', $logDir . '/package_relations.html', $consolidated, $history);
78
+        $this->renderPage(__DIR__.'/template/index.php', $logDir.'/index.html', $consolidated, $history);
79
+        $this->renderPage(__DIR__.'/template/loc.php', $logDir.'/loc.html', $consolidated, $history);
80
+        $this->renderPage(__DIR__.'/template/relations.php', $logDir.'/relations.html', $consolidated, $history);
81
+        $this->renderPage(__DIR__.'/template/coupling.php', $logDir.'/coupling.html', $consolidated, $history);
82
+        $this->renderPage(__DIR__.'/template/all.php', $logDir.'/all.html', $consolidated, $history);
83
+        $this->renderPage(__DIR__.'/template/oop.php', $logDir.'/oop.html', $consolidated, $history);
84
+        $this->renderPage(__DIR__.'/template/complexity.php', $logDir.'/complexity.html', $consolidated, $history);
85
+        $this->renderPage(__DIR__.'/template/panel.php', $logDir.'/panel.html', $consolidated, $history);
86
+        $this->renderPage(__DIR__.'/template/violations.php', $logDir.'/violations.html', $consolidated, $history);
87
+        $this->renderPage(__DIR__.'/template/packages.php', $logDir.'/packages.html', $consolidated, $history);
88
+        $this->renderPage(__DIR__.'/template/package_relations.php', $logDir.'/package_relations.html', $consolidated, $history);
89 89
         if ($this->config->has('git')) {
90
-            $this->renderPage(__DIR__ . '/template/git.php', $logDir . '/git.html', $consolidated, $history);
90
+            $this->renderPage(__DIR__.'/template/git.php', $logDir.'/git.html', $consolidated, $history);
91 91
         }
92
-        $this->renderPage(__DIR__ . '/template/junit.php', $logDir . '/junit.html', $consolidated, $history);
92
+        $this->renderPage(__DIR__.'/template/junit.php', $logDir.'/junit.html', $consolidated, $history);
93 93
 
94 94
         // js data
95 95
         file_put_contents(
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 
104 104
         // json data
105 105
         file_put_contents(
106
-            $logDir . '/js/classes.js',
107
-            'var classes = ' . json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT)
106
+            $logDir.'/js/classes.js',
107
+            'var classes = '.json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT)
108 108
         );
109 109
 
110 110
         $this->output->writeln(sprintf('HTML report generated in "%s" directory', $logDir));
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
         $diff = $newValue - $oldValue;
175 175
         if ($diff > 0) {
176
-            $diff = '+' . $diff;
176
+            $diff = '+'.$diff;
177 177
         }
178 178
 
179 179
         $goodOrBad = 'neutral';
Please login to merge, or discard this patch.
src/Hal/Violation/Package/StableAbstractionsPrinciple.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.