| Total Complexity | 7 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | trait HasControllerRecordsTrait |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var null|string |
||
| 14 | */ |
||
| 15 | protected $controller = null; |
||
| 16 | /** |
||
| 17 | * @return string |
||
| 18 | */ |
||
| 19 | 15 | public function getController() |
|
| 20 | { |
||
| 21 | 15 | if ($this->controller === null) { |
|
| 22 | 15 | $this->initController(); |
|
| 23 | } |
||
| 24 | |||
| 25 | 15 | return $this->controller; |
|
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param null|string $controller |
||
| 30 | */ |
||
| 31 | 15 | public function setController($controller) |
|
| 32 | { |
||
| 33 | 15 | $this->controller = $controller; |
|
| 34 | 15 | } |
|
| 35 | |||
| 36 | 15 | protected function initController() |
|
| 37 | { |
||
| 38 | 15 | if ($this->isNamespaced()) { |
|
|
|
|||
| 39 | 10 | $controller = $this->generateControllerNamespaced(); |
|
| 40 | } else { |
||
| 41 | 5 | $controller = $this->generateControllerGeneric(); |
|
| 42 | } |
||
| 43 | 15 | $this->setController($controller); |
|
| 44 | 15 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | 10 | protected function generateControllerNamespaced() |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | 5 | protected function generateControllerGeneric() |
|
| 65 | } |
||
| 66 | } |
||
| 67 |