| Total Complexity | 3 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class NotInstantiableWithoutWidgetFactoryInitializationException extends NotInstantiableException implements FriendlyExceptionInterface |
||
| 12 | { |
||
| 13 | 1 | public function __construct( |
|
| 14 | private string $widgetClassName, |
||
| 15 | private Throwable $previous, |
||
| 16 | ) |
||
| 17 | { |
||
| 18 | 1 | parent::__construct( |
|
| 19 | 1 | 'Failed to create a widget "' . $this->widgetClassName . '". '. $previous->getMessage() . |
|
| 20 | 1 | ' Perhaps you need to initialize "' . WidgetFactory::class . '" with DI container to resolve dependencies.', |
|
| 21 | 1 | previous: $previous, |
|
| 22 | 1 | ); |
|
| 23 | } |
||
| 24 | |||
| 25 | 1 | public function getName(): string |
|
| 26 | { |
||
| 27 | 1 | return 'Failed to create a widget "' . $this->widgetClassName . '". ' . $this->previous->getMessage(); |
|
| 28 | } |
||
| 29 | |||
| 30 | 1 | public function getSolution(): ?string |
|
| 36 | |||
| 37 | To initialize the widget factory call `WidgetFactory::initialize()` before using the widget. |
||
| 38 | It is a good idea to do that for the whole application. |
||
| 65 |