| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function __invoke(string $expression): string |
||
| 19 | { |
||
| 20 | $expressionParts = explode(',', $expression, 2); |
||
| 21 | |||
| 22 | $componentClass = $this->componentFinder->find($expressionParts[0]); |
||
| 23 | |||
| 24 | if (!class_exists($componentClass)) { |
||
| 25 | throw new InvalidArgumentException("View component [{$componentClass}] not found."); |
||
| 26 | } |
||
| 27 | |||
| 28 | if (!array_key_exists(Htmlable::class, class_implements($componentClass))) { |
||
| 29 | throw new InvalidArgumentException( |
||
| 30 | "View component [{$componentClass}] must implement Illuminate\Support\Htmlable." |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | $props = trim($expressionParts[1] ?? '[]'); |
||
| 35 | |||
| 36 | return "<?php echo app()->make({$componentClass}::class, {$props})->toHtml(); ?>"; |
||
| 37 | } |
||
| 38 | } |
||
| 39 |