Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
13 | 18 | public function create(string $template, array $arguments): array |
|
14 | { |
||
15 | 18 | $command = []; |
|
16 | 18 | $parts = array_filter(explode(' ', $template), function (string $part): bool { |
|
17 | 18 | return ('' !== $part); |
|
18 | }); |
||
19 | |||
20 | 18 | $argumentPosition = 0; |
|
21 | 18 | foreach ($parts as $value) { |
|
22 | 18 | if ('?' === $value) { // argument insert |
|
23 | 17 | $value = $arguments[$argumentPosition] ?? ''; |
|
24 | 17 | $argumentPosition = $argumentPosition + 1; |
|
25 | } |
||
26 | 18 | $command[] = $value; |
|
27 | } |
||
28 | |||
29 | 18 | return $command; |
|
30 | } |
||
32 |