Conditions | 7 |
Paths | 5 |
Total Lines | 50 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Tests | 29 |
CRAP Score | 7 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
31 | 12 | public function __invoke(Activity $activity, Environment $env): void |
|
32 | { |
||
33 | if ( |
||
34 | 12 | !$activity->is(Type::sourcesModified()) && |
|
35 | 12 | !$activity->is(Type::testsModified()) |
|
36 | ) { |
||
37 | 2 | return; |
|
38 | } |
||
39 | |||
40 | 10 | $directory = $this->filesystem->mount($env->workingDirectory()); |
|
41 | |||
42 | 10 | if (!$directory->has('psalm.xml')) { |
|
43 | 2 | return; |
|
44 | } |
||
45 | |||
46 | 8 | $output = $env->output(); |
|
47 | 8 | $error = $env->error(); |
|
48 | |||
49 | $process = $this |
||
50 | 8 | ->processes |
|
51 | 8 | ->execute( |
|
52 | 8 | Command::foreground('vendor/bin/psalm') |
|
53 | 8 | ->withWorkingDirectory((string) $env->workingDirectory()) |
|
54 | ); |
||
55 | $process |
||
56 | 8 | ->output() |
|
57 | ->foreach(static function(Str $line, Output\Type $type) use ($output, $error): void { |
||
58 | 4 | if ($type === Output\Type::output()) { |
|
59 | 4 | $output->write($line); |
|
60 | } else { |
||
61 | 4 | $error->write($line); |
|
62 | } |
||
63 | 8 | }); |
|
64 | 8 | $process->wait(); |
|
65 | |||
66 | 8 | if ($env->arguments()->contains('--silent')) { |
|
67 | 2 | return; |
|
68 | } |
||
69 | |||
70 | 6 | $successful = $process->exitCode()->isSuccessful(); |
|
71 | 6 | $text = 'Psalm : '; |
|
72 | 6 | $text .= $successful ? 'ok' : 'failing'; |
|
73 | |||
74 | $this |
||
75 | 6 | ->processes |
|
76 | 6 | ->execute( |
|
77 | 6 | Command::foreground('say') |
|
78 | 6 | ->withArgument($text) |
|
79 | ) |
||
80 | 6 | ->wait(); |
|
81 | 6 | } |
|
83 |