Total Complexity | 3 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | class PropelCommandProvider implements PropelCommandProviderInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $propelCommand; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $rootDirectory; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $configDir; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | private $result; |
||
31 | |||
32 | /** |
||
33 | * PropelCommandProvider constructor. |
||
34 | * |
||
35 | * @param string $propelCommand |
||
36 | * @param string $rootDirectory |
||
37 | * @param string $configDir |
||
38 | */ |
||
39 | 2 | public function __construct(string $propelCommand, string $rootDirectory, string $configDir) |
|
40 | { |
||
41 | 2 | $this->propelCommand = $propelCommand; |
|
42 | 2 | $this->rootDirectory = $rootDirectory; |
|
43 | 2 | $this->configDir = $configDir; |
|
44 | 2 | } |
|
45 | |||
46 | |||
47 | /** |
||
48 | * @param string $command |
||
49 | * |
||
50 | * @return array |
||
51 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
52 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
53 | */ |
||
54 | 2 | public function execute(string $command) : array |
|
55 | { |
||
56 | 2 | $this->result = []; |
|
57 | 2 | $process = new Process( |
|
58 | 2 | $this->propelCommand . ' ' . $command . ' --config-dir=' . $this->configDir, |
|
|
|||
59 | 2 | $this->rootDirectory |
|
60 | ); |
||
61 | |||
62 | 2 | $process->run([$this, 'handle']); |
|
63 | |||
64 | 2 | return $this->result; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param mixed $type |
||
69 | * @param mixed $buffer |
||
70 | */ |
||
71 | 2 | public function handle($type, $buffer): void |
|
76 | ]; |
||
77 | 2 | } |
|
78 | } |
||
79 |