Conditions | 3 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3.0261 |
Changes | 0 |
1 | <?php |
||
15 | 24 | public function normalize($widget): void |
|
16 | { |
||
17 | // class name without namespace. |
||
18 | 24 | $className = str_replace(app()->getNamespace().'Widgets\\', '', get_class($widget)); |
|
|
|||
19 | |||
20 | // replace slashes with dots |
||
21 | 24 | $className = str_replace(['\\', '/'], '.', $className); |
|
22 | |||
23 | 24 | if (! property_exists($widget, 'template')) { |
|
24 | 1 | $widget->template = 'Widgets::'.$className.'View'; |
|
25 | } |
||
26 | |||
27 | 24 | if (! view()->exists($widget->template)) { |
|
28 | throw new \InvalidArgumentException("View file \"{$widget->template}\" not found by: '".get_class($widget)." '"); |
||
29 | } |
||
32 |