| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function renderString(string $string, array $context = []): string |
||
| 12 | { |
||
| 13 | if (null === $this->twig) { |
||
| 14 | return $string; |
||
| 15 | } |
||
| 16 | |||
| 17 | $key = sprintf('__behapi_tpl__%s', hash('sha256', $string)); |
||
| 18 | |||
| 19 | // this is assuming that the loader is Twig_Loader_Array |
||
| 20 | // as this was privately set in the initializer, it should be OK |
||
| 21 | // to assume that this is still a Twig_Loader_Array |
||
| 22 | $loader = $this->twig->getLoader(); |
||
| 23 | $loader->setTemplate($key, $string); |
||
| 24 | |||
| 25 | return $this->twig->load($key)->render($context); |
||
| 26 | } |
||
| 27 | } |
||
| 29 |