Conditions | 4 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | public function parse(string $str): array |
||
13 | { |
||
14 | preg_match_all('/%([A-Z_]+)%/', $str, $matches); |
||
15 | |||
16 | if (!isset($matches[0]) || count($matches[0]) === 0) { |
||
17 | return []; |
||
18 | } |
||
19 | |||
20 | $variables = []; |
||
21 | |||
22 | foreach ($matches[0] as $key => $value) { |
||
23 | $name = $matches[1][$key]; |
||
24 | $variables[] = new Variable($value, $name); |
||
25 | } |
||
26 | |||
27 | return $variables; |
||
28 | } |
||
30 |