SynchronousProcessRunner::runProcesses()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * File: SynchronousProcessRunner.php
6
 *
7
 * @author      Maciej Sławik <[email protected]>
8
 * Github:      https://github.com/maciejslawik
9
 */
10
11
namespace MSlwk\ReactPhpPlayground\Standalone\ChildProcess;
12
13
use MSlwk\ReactPhpPlayground\Api\Data\ProcessInterface;
14
use MSlwk\TypeSafeArray\ObjectArray;
15
16
/**
17
 * Class SynchronousProcessRunner
18
 * @package MSlwk\ReactPhpPlayground\Standalone\ChildProcess
19
 */
20
class SynchronousProcessRunner implements ProcessRunnerInterface
21
{
22
    /**
23
     * @param ObjectArray $processes
24
     * @return void
25
     */
26
    public function runProcesses(ObjectArray $processes): void
27
    {
28
        /** @var ProcessInterface $process */
29
        foreach ($processes as $process) {
30
            $output = $this->execWrapper($process->getCommand());
31
            echo $output . PHP_EOL;
32
        }
33
    }
34
35
    /**
36
     * @codeCoverageIgnore
37
     * @param string $command
38
     * @return string
39
     */
40
    protected function execWrapper(string $command): string
41
    {
42
        return exec($command);
43
    }
44
}
45