| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3.4746 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | 1 | protected function fetchController($name) |
|
| 30 | { |
||
| 31 | // Derive the controller class name. |
||
| 32 | 1 | $class = $this->controllerPrefix . ucfirst($name); |
|
| 33 | |||
| 34 | // If the controller class does not exist panic. |
||
| 35 | 1 | if (!class_exists($class)) |
|
| 36 | { |
||
| 37 | throw new \RuntimeException(sprintf('Unable to locate controller `%s`.', $class), 404); |
||
| 38 | } |
||
| 39 | |||
| 40 | // If the controller does not follows the implementation. |
||
| 41 | 1 | if (!is_subclass_of($class, 'Joomla\\Controller\\ControllerInterface')) |
|
|
|
|||
| 42 | { |
||
| 43 | throw new \RuntimeException( |
||
| 44 | sprintf('Invalid Controller. Controllers must implement Joomla\Controller\ControllerInterface. `%s`.', $class), 500 |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | |||
| 48 | // Instantiate the controller. |
||
| 49 | 1 | return $this->getContainer()->get($class); |
|
| 50 | } |
||
| 51 | } |
||
| 52 |