| Conditions | 3 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function normalizeTemplateName($widget) |
||
| 13 | { |
||
| 14 | // class name without namespace. |
||
| 15 | $className = str_replace('App\\Widgets\\', '', class_basename($widget)); |
||
| 16 | |||
| 17 | // replace slashes with dots |
||
| 18 | $className = str_replace(['\\', '/'], '.', $className); |
||
| 19 | |||
| 20 | if ($widget->template === null) { |
||
| 21 | $widget->template = 'Widgets::' . $className . 'View'; |
||
| 22 | } |
||
| 23 | |||
| 24 | if (!view()->exists($widget->template)) { |
||
|
1 ignored issue
–
show
|
|||
| 25 | throw new \InvalidArgumentException("View file [{$className}View] not found by: '" . class_basename($widget) . " '"); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | } |
||
| 29 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: