| Conditions | 5 |
| Paths | 3 |
| Total Lines | 30 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | 6 | public function __invoke(Activity $activity, Environment $env): void |
|
| 32 | { |
||
| 33 | 6 | if (!$activity->is(Type::start())) { |
|
| 34 | 2 | return; |
|
| 35 | } |
||
| 36 | |||
| 37 | 4 | $output = $env->output(); |
|
| 38 | 4 | $error = $env->error(); |
|
| 39 | |||
| 40 | 4 | $ask = new Question('Update dependencies? [Y/n]'); |
|
| 41 | 4 | $response = (string) $ask($env->input(), $output); |
|
| 42 | |||
| 43 | 4 | if (($response ?: 'y') === 'n') { |
|
| 44 | 2 | return; |
|
| 45 | } |
||
| 46 | |||
| 47 | $this |
||
| 48 | 2 | ->processes |
|
| 49 | 2 | ->execute( |
|
| 50 | 2 | Command::foreground('composer') |
|
| 51 | 2 | ->withOption('ansi') |
|
| 52 | 2 | ->withArgument('update') |
|
| 53 | 2 | ->withWorkingDirectory((string) $env->workingDirectory()) |
|
| 54 | ) |
||
| 55 | 2 | ->output() |
|
| 56 | ->foreach(static function(Str $line, Output\Type $type) use ($output, $error): void { |
||
| 57 | 2 | if ($type === Output\Type::output()) { |
|
| 58 | 2 | $output->write($line); |
|
| 59 | } else { |
||
| 60 | 2 | $error->write($line); |
|
| 61 | } |
||
| 65 |