Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | 24 | * @see https://www.regextester.com/97707 |
|
14 | */ |
||
15 | 24 | public function hydrate(string $text, string $pattern = '/[^{{\}\}]+(?=}})/'): string |
|
16 | { |
||
17 | 24 | preg_match_all($pattern, $text, $matches); |
|
18 | 23 | ||
19 | if (0 === \count($matches[0])) { |
||
20 | return $text; |
||
21 | 2 | } |
|
22 | |||
23 | 2 | $replace_vars = []; |
|
24 | 2 | ||
25 | 2 | foreach ($matches[0] as $match) { |
|
26 | $var = Str::slug($match, '_'); |
||
27 | $replace_vars["{{{$match}}}"] = $this->store->get($var, "{{$var}}"); |
||
28 | 2 | } |
|
29 | |||
44 |