Conditions | 6 |
Paths | 7 |
Total Lines | 28 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | public function call() |
||
17 | { |
||
18 | $builder = $this->getBuilder(); |
||
19 | |||
20 | $commands = $this->getParam('commands', []); |
||
21 | |||
22 | foreach ($commands as $command => $data) { |
||
23 | $result = $data['result'] ?? null; |
||
24 | $dir = $data['dir'] ?? null; |
||
25 | $timeout = $data['timeout'] ?? 5; |
||
26 | |||
27 | $process = new Process($command, $dir); |
||
28 | $process->run(); |
||
29 | |||
30 | if ($timeout) { |
||
31 | $process->setTimeout($timeout); |
||
32 | } |
||
33 | |||
34 | $output = $process->getOutput(); |
||
35 | |||
36 | if (! $process->isSuccessful()) { |
||
37 | $builder->down(); |
||
38 | } elseif ($result && ! preg_match("|{$result}|", $output)) { |
||
39 | $builder->down(); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | return $builder->build(); |
||
44 | } |
||
46 |