Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | public function resolve(string $str): string |
||
24 | { |
||
25 | $variables = $this->parser->parse($str); |
||
26 | |||
27 | if (count($variables) === 0) { |
||
28 | return $str; |
||
29 | } |
||
30 | |||
31 | foreach ($variables as $variable) { |
||
32 | if (!isset($this->values[$variable->getName()])) { |
||
33 | throw new \InvalidArgumentException(sprintf('The variable, "%s" does not have a corresponding variable value. Please add one.', $variable->getName())); // todo better exception |
||
34 | } |
||
35 | |||
36 | $str = str_replace($variable->getValue(), $this->values[$variable->getName()]->getValue(), $str); |
||
37 | } |
||
38 | |||
39 | return $str; |
||
40 | } |
||
47 |