| Total Complexity | 8 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 12 | class ResponsePayloadFactory |
||
| 13 | { |
||
| 14 | protected $controller = null; |
||
| 15 | protected $request = null; |
||
| 16 | protected ?ResponsePayload $payload = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param $controller |
||
| 20 | * @return ResponsePayload |
||
| 21 | */ |
||
| 22 | public static function fromController($controller): ResponsePayload |
||
| 23 | { |
||
| 24 | $factory = new self(); |
||
| 25 | $factory->controller = $controller; |
||
| 26 | $factory->request = $controller->getRequest(); |
||
| 27 | return $factory->create(); |
||
| 28 | } |
||
| 29 | |||
| 30 | protected function create(): ResponsePayload |
||
| 31 | { |
||
| 32 | $this->payload = $this->new(); |
||
| 33 | $this->checkDefault(); |
||
| 34 | $this->checkRequestQuery(); |
||
| 35 | return $this->payload; |
||
| 36 | } |
||
| 37 | |||
| 38 | protected function new(): ResponsePayload |
||
| 39 | { |
||
| 40 | return new ResponsePayload(); |
||
| 41 | } |
||
| 42 | |||
| 43 | protected function checkDefault() |
||
| 44 | { |
||
| 45 | if (method_exists($this->controller, 'getView')) { |
||
| 46 | $this->payload->withDefaultFormat('view'); |
||
|
|
|||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | protected function checkRequestQuery() |
||
| 61 | } |
||
| 62 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.