@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | private readonly ReaderInterface $fileReader, |
59 | 59 | private readonly ViewHelper $viewHelper |
60 | 60 | ) { |
61 | - $this->templateDir = dirname(__DIR__, 4) . '/templates/html_report/'; |
|
61 | + $this->templateDir = dirname(__DIR__, 4).'/templates/html_report/'; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | if (null === $logDir) { |
74 | 74 | return; |
75 | 75 | } |
76 | - $logDir = rtrim($logDir, '/') . '/'; |
|
76 | + $logDir = rtrim($logDir, '/').'/'; |
|
77 | 77 | $this->fileWriter->ensureDirectoryExists($logDir); |
78 | 78 | if (!$this->fileWriter->isWritable($logDir)) { |
79 | 79 | throw new RuntimeException(sprintf('Unable to write in the directory "%s"', $logDir)); |
@@ -91,35 +91,35 @@ discard block |
||
91 | 91 | $consolidated = new Consolidated($metrics); |
92 | 92 | |
93 | 93 | // history of builds |
94 | - $today = (object)[ |
|
94 | + $today = (object) [ |
|
95 | 95 | 'avg' => $consolidated->getAvg(), |
96 | 96 | 'sum' => $consolidated->getSum() |
97 | 97 | ]; |
98 | 98 | /** @var array<string> $files */ |
99 | - $files = $this->fileReader->glob($logDir . 'js/history-*.json'); |
|
99 | + $files = $this->fileReader->glob($logDir.'js/history-*.json'); |
|
100 | 100 | natsort($files); |
101 | 101 | /** @var array<stdClass> $history */ |
102 | 102 | $history = array_map($this->fileReader->readJson(...), array_values($files)); |
103 | 103 | |
104 | 104 | // copy sources |
105 | - $this->fileWriter->copy($this->templateDir . 'favicon.ico', $logDir . 'favicon.ico'); |
|
106 | - $this->fileWriter->recursiveCopy($this->templateDir . 'js', $logDir . 'js'); |
|
107 | - $this->fileWriter->recursiveCopy($this->templateDir . 'css', $logDir . 'css'); |
|
108 | - $this->fileWriter->recursiveCopy($this->templateDir . 'images', $logDir . 'images'); |
|
109 | - $this->fileWriter->recursiveCopy($this->templateDir . 'fonts', $logDir . 'fonts'); |
|
105 | + $this->fileWriter->copy($this->templateDir.'favicon.ico', $logDir.'favicon.ico'); |
|
106 | + $this->fileWriter->recursiveCopy($this->templateDir.'js', $logDir.'js'); |
|
107 | + $this->fileWriter->recursiveCopy($this->templateDir.'css', $logDir.'css'); |
|
108 | + $this->fileWriter->recursiveCopy($this->templateDir.'images', $logDir.'images'); |
|
109 | + $this->fileWriter->recursiveCopy($this->templateDir.'fonts', $logDir.'fonts'); |
|
110 | 110 | // render dynamic pages |
111 | 111 | $this->renderHtmlPages($logDir, $consolidated, $history); |
112 | 112 | |
113 | 113 | // js data |
114 | - $this->fileWriter->writePrettyJson($logDir . sprintf('js/history-%d.json', count($files) + 1), $today); |
|
115 | - $this->fileWriter->writePrettyJson($logDir . 'js/latest.json', $today); |
|
114 | + $this->fileWriter->writePrettyJson($logDir.sprintf('js/history-%d.json', count($files) + 1), $today); |
|
115 | + $this->fileWriter->writePrettyJson($logDir.'js/latest.json', $today); |
|
116 | 116 | |
117 | 117 | // consolidated by groups |
118 | 118 | foreach ($consolidatedGroups as $name => $consolidatedGroup) { |
119 | 119 | $this->currentGroup = $name; |
120 | 120 | $this->assetPath = '../'; |
121 | 121 | |
122 | - $this->renderHtmlPages($logDir . $name . '/', $consolidatedGroup, $history); |
|
122 | + $this->renderHtmlPages($logDir.$name.'/', $consolidatedGroup, $history); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $this->output->writeln(sprintf('HTML report generated in "%s" directory', $logDir)); |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | ); |
162 | 162 | |
163 | 163 | $this->fileWriter->write( |
164 | - $destination . 'classes.js', |
|
165 | - 'var classes = ' . json_encode($consolidated->getClasses(), JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT) |
|
164 | + $destination.'classes.js', |
|
165 | + 'var classes = '.json_encode($consolidated->getClasses(), JSON_THROW_ON_ERROR|JSON_PRETTY_PRINT) |
|
166 | 166 | ); |
167 | 167 | } |
168 | 168 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | throw new RuntimeException(sprintf('Unable to write in the directory "%s"', dirname($destination))); |
180 | 180 | } |
181 | 181 | |
182 | - $this->sharedMetrics = (object)[ |
|
182 | + $this->sharedMetrics = (object) [ |
|
183 | 183 | 'sum' => $consolidated->getSum(), |
184 | 184 | 'avg' => $consolidated->getAvg(), |
185 | 185 | 'classes' => $consolidated->getClasses(), |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $oldValue, |
243 | 243 | $trendNames[$trendIndex], |
244 | 244 | $trendCodes[$trendIndex], |
245 | - ($diff > 0) ? '+' . round($diff, 3) : round($diff, 3), |
|
245 | + ($diff > 0) ? '+'.round($diff, 3) : round($diff, 3), |
|
246 | 246 | $svg[$trendCodes[$trendIndex]] |
247 | 247 | ); |
248 | 248 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | */ |
61 | 61 | private function generateRowData(ClassMetric $metric): array |
62 | 62 | { |
63 | - return array_map(static function (string $key) use ($metric): string|int|bool|float { |
|
63 | + return array_map(static function(string $key) use ($metric): string|int|bool|float { |
|
64 | 64 | $value = $metric->get($key); |
65 | 65 | return is_scalar($value) ? $value : 'N/A'; |
66 | 66 | }, Registry::allForStructures()); |
@@ -62,7 +62,7 @@ |
||
62 | 62 | $title = sprintf('<%s>Found %d occurrences for search "%s"</%s>', $tag, $nbFound, $searchName, $tag); |
63 | 63 | $this->output->writeln($title); |
64 | 64 | |
65 | - array_map(function (Metric $metric): void { |
|
65 | + array_map(function(Metric $metric): void { |
|
66 | 66 | $this->output->writeln(sprintf('- %s', $metric->getName())); |
67 | 67 | }, array_splice($metricsListInViolation, 0, 5)); |
68 | 68 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | public function writeln(string $message): void |
18 | 18 | { |
19 | - $this->write(PHP_EOL . $message); |
|
19 | + $this->write(PHP_EOL.$message); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | public function addEdge(Node $from, Node $to): void |
16 | 16 | { |
17 | - $key = $from->getUniqueId() . '➔' . $to->getUniqueId(); |
|
17 | + $key = $from->getUniqueId().'➔'.$to->getUniqueId(); |
|
18 | 18 | |
19 | 19 | if (isset($this->edgesMap[$key])) { |
20 | 20 | return; |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | { |
32 | 32 | $pregExcludedDirs = '.+'; |
33 | 33 | if ([] !== $excludedDirs) { |
34 | - $pregExcludedDirs = '((?!' . implode('|', array_map(preg_quote(...), $excludedDirs)) . ').)+'; |
|
34 | + $pregExcludedDirs = '((?!'.implode('|', array_map(preg_quote(...), $excludedDirs)).').)+'; |
|
35 | 35 | } |
36 | - $pregExtensions = '\.(' . implode('|', $extensions) . ')'; |
|
36 | + $pregExtensions = '\.('.implode('|', $extensions).')'; |
|
37 | 37 | |
38 | 38 | // Regular expression that needs to be filled with a path to filter all files. |
39 | - $this->pathFilterRegex = '`^%s' . $pregExcludedDirs . $pregExtensions . '$`'; |
|
39 | + $this->pathFilterRegex = '`^%s'.$pregExcludedDirs.$pregExtensions.'$`'; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if (is_file($path)) { |
50 | 50 | $files[] = $path; |
51 | 51 | } elseif (is_dir($path)) { |
52 | - $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
52 | + $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
53 | 53 | |
54 | 54 | // Each iteration produces an array of a single file matching the regular expression set in constructor. |
55 | 55 | /** @var RegexIterator<array{string}> $filteredIterator */ |
@@ -70,7 +70,7 @@ |
||
70 | 70 | } |
71 | 71 | $content = file_get_contents($uri, context: stream_context_create(['http' => $httpOptions])); |
72 | 72 | if (false === $content) { |
73 | - return (object)[]; |
|
73 | + return (object) []; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /* @TODO: Remove @noinspection once https://github.com/kalessil/phpinspectionsea/issues/1725 fixed. */ |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | /** @var resource $csvHandler */ |
44 | 44 | $csvHandler = fopen($path, 'wb'); |
45 | 45 | fputcsv($csvHandler, $header); |
46 | - array_map(static function (array $line) use ($csvHandler): void { |
|
46 | + array_map(static function(array $line) use ($csvHandler): void { |
|
47 | 47 | fputcsv($csvHandler, $line); |
48 | 48 | }, $data); |
49 | 49 | fclose($csvHandler); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function writePrettyJson(string $path, mixed $data): void |
57 | 57 | { |
58 | - $this->write($path, json_encode($data, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)); |
|
58 | + $this->write($path, json_encode($data, JSON_THROW_ON_ERROR|JSON_PRETTY_PRINT)); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | $relativeName = substr_replace($file->getPathname(), '', 0, strlen($src)); |
91 | 91 | |
92 | 92 | if ($file->isDir()) { |
93 | - mkdir($dest . '/' . $relativeName); |
|
93 | + mkdir($dest.'/'.$relativeName); |
|
94 | 94 | } else { |
95 | - copy($file->getPathname(), $dest . '/' . $relativeName); |
|
95 | + copy($file->getPathname(), $dest.'/'.$relativeName); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -chdir(__DIR__ . '/../../'); |
|
2 | +chdir(__DIR__.'/../../'); |
|
3 | 3 | |
4 | 4 | if (!file_exists('vendor/autoload.php')) { |
5 | - echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!' . PHP_EOL; |
|
5 | + echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!'.PHP_EOL; |
|
6 | 6 | exit(1); |
7 | 7 | } |
8 | 8 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | foreach ($files as $file) { |
31 | - $phar->addFromString(str_replace(__DIR__ . '/', '', $file), file_get_contents($file)); |
|
31 | + $phar->addFromString(str_replace(__DIR__.'/', '', $file), file_get_contents($file)); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | $phar->setStub(<<<'STUB' |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | |
67 | 67 | function rglob($pattern = '*', $flags = 0, $path = '') |
68 | 68 | { |
69 | - $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT); |
|
70 | - $files = glob($path . $pattern, $flags); |
|
69 | + $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); |
|
70 | + $files = glob($path.$pattern, $flags); |
|
71 | 71 | foreach ($paths as $path) { |
72 | 72 | $files = array_merge($files, rglob($pattern, $flags, $path)); |
73 | 73 | } |