| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | public function applyFunction(string $string): string |
||
| 12 | { |
||
| 13 | if ($this->functionName == '') { |
||
| 14 | throw new \RuntimeException('The function name must be set'); |
||
| 15 | } |
||
| 16 | |||
| 17 | $pattern = '#' . preg_quote(StringEnrichFunction::FUNCTION_LIMITER_START) . $this->functionName . '\((.*?)\)' . preg_quote(StringEnrichFunction::FUNCTION_LIMITER_END) . '#'; |
||
| 18 | preg_match_all($pattern, $string, $matches); |
||
| 19 | if (count($matches) > 0) { |
||
| 20 | foreach ($matches[1] as $functionValue) { |
||
| 21 | $string = str_replace(StringEnrichFunction::FUNCTION_LIMITER_START . $this->functionName . '(' . $functionValue . ')' . StringEnrichFunction::FUNCTION_LIMITER_END, $this->getValue($functionValue), $string); |
||
| 22 | } |
||
| 23 | } |
||
| 24 | return $string; |
||
| 25 | } |
||
| 29 |