| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 42 | protected function view($view, $data) |
||
| 43 | { |
||
| 44 | if (false === strpos($view, ':')) { |
||
| 45 | $class = preg_replace(['#\\\\Controller\\\\#', '#Controller$#'], ['\\View\\', 'View'], get_class($this)); |
||
| 46 | $view = $class . '::' . $view; |
||
| 47 | } |
||
| 48 | |||
| 49 | return call_user_func( |
||
| 50 | $this->viewResolver->getView($view), |
||
| 51 | $data |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | } |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.