| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function compile(string $viewContents): string |
||
| 18 | { |
||
| 19 | foreach ($this->bladeX->getRegisteredComponents() as $componentName => $viewPath) { |
||
| 20 | $pattern = '/<\s*' . $componentName . '[^>]*>((.|\n)*?)<\s*\/\s*' . $componentName . '>/m'; |
||
| 21 | |||
| 22 | $viewContents = preg_replace_callback($pattern, function (array $regexResult) use ($viewPath) { |
||
| 23 | [$componentHtml, $componentInnerHtml] = $regexResult; |
||
| 24 | |||
| 25 | return "@component('{$viewPath}', [{$this->getComponentAttributes($componentHtml)}])" |
||
| 26 | . $this->parseComponentInnerHtml($componentInnerHtml) |
||
| 27 | . '@endcomponent'; |
||
| 28 | }, $viewContents); |
||
| 29 | } |
||
| 30 | |||
| 31 | return $viewContents; |
||
| 32 | } |
||
| 33 | |||
| 57 |