SynchronousProcessRunner   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 25
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A runProcesses() 0 8 2
A execWrapper() 0 4 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