Skip to content

Commit 2934960

Browse files
committed
refactor
1 parent deae6b1 commit 2934960

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/Commands/CheckPsr4.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ public function handle(ErrorPrinter $errorPrinter)
4040
$this->fixReferences($autoload, $olds, $news);
4141
}
4242
if (Str::startsWith(request()->server('argv')[1] ?? '', 'check:psr4')) {
43-
$this->getOutput()->writeln('');
44-
$this->getOutput()->writeln('<fg=green>Finished!</fg=green>');
45-
$this->getOutput()->writeln('==============================');
46-
$this->getOutput()->writeln('<options=bold;fg=yellow>'.CheckNamespaces::$checkedNamespaces.' classes were checked under:</>');
47-
$this->getOutput()->writeln(' - '.implode("\n - ", array_keys($autoload)).'');
43+
$this->reportResult($autoload);
4844
$this->printErrorsCount($errorPrinter, $time);
4945
} else {
5046
$this->getOutput()->writeln(' - '.CheckNamespaces::$checkedNamespaces.' namespaces were checked.');
@@ -175,20 +171,34 @@ private function checkNamespaces(array $autoload)
175171
}
176172
}
177173

178-
private function report(string $_path, $line)
174+
private function report($_path, $line)
179175
{
180176
app(ErrorPrinter::class)->simplePendError($_path, $line, '', 'ns_replacement', 'Namespace replacement:');
181177
}
182178

183179
private function printErrorsCount($errorPrinter, $time)
184180
{
185181
if ($errorCount = $errorPrinter->errorsList['total']) {
186-
$errorCount && $this->warn(PHP_EOL.$errorCount.' error(s) found in namespaces');
182+
$this->warn(PHP_EOL.$errorCount.' error(s) found in namespaces');
187183
} else {
188-
$time = microtime(true) - $time;
189-
$this->line(PHP_EOL.'<fg=green>All namespaces are correct!</><fg=blue> You rock \(^_^)/ </>');
190-
$this->line('<fg=red;options=bold>'.round($time, 5).'(s)</>');
191-
$this->line('');
184+
$this->noErrorFound($time);
192185
}
193186
}
187+
188+
private function reportResult($autoload)
189+
{
190+
$this->getOutput()->writeln('');
191+
$this->getOutput()->writeln('<fg=green>Finished!</fg=green>');
192+
$this->getOutput()->writeln('==============================');
193+
$this->getOutput()->writeln('<options=bold;fg=yellow>'.CheckNamespaces::$checkedNamespaces.' classes were checked under:</>');
194+
$this->getOutput()->writeln(' - '.implode("\n - ", array_keys($autoload)).'');
195+
}
196+
197+
private function noErrorFound($time)
198+
{
199+
$time = microtime(true) - $time;
200+
$this->line(PHP_EOL.'<fg=green>All namespaces are correct!</><fg=blue> You rock \(^_^)/ </>');
201+
$this->line('<fg=red;options=bold>'.round($time, 5).'(s)</>');
202+
$this->line('');
203+
}
194204
}

0 commit comments

Comments
 (0)