jasny /
controller
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Jasny; |
||
| 4 | |||
| 5 | use Psr\Http\Message\ServerRequestInterface; |
||
| 6 | use Psr\Http\Message\ResponseInterface; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Controller |
||
| 10 | */ |
||
| 11 | abstract class Controller |
||
| 12 | { |
||
| 13 | use Controller\Input, |
||
| 14 | Controller\Output, |
||
| 15 | Controller\CheckRequest, |
||
| 16 | Controller\CheckResponse; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Server request |
||
| 20 | * @var ServerRequestInterface |
||
| 21 | **/ |
||
| 22 | protected $request = null; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Response |
||
| 26 | * @var ResponseInterface |
||
| 27 | **/ |
||
| 28 | protected $response = null; |
||
| 29 | |||
| 30 | |||
| 31 | /** |
||
| 32 | * Get request, set for controller |
||
| 33 | * |
||
| 34 | * @return ServerRequestInterface |
||
| 35 | */ |
||
| 36 | 2 | public function getRequest() |
|
| 37 | { |
||
| 38 | 2 | if (!isset($this->request)) { |
|
| 39 | 1 | throw new \LogicException("Request not set, the controller has not been invoked"); |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | return $this->request; |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Get response. set for controller |
||
| 47 | * |
||
| 48 | * @return ResponseInterface |
||
| 49 | */ |
||
| 50 | 3 | public function getResponse() |
|
| 51 | { |
||
| 52 | 3 | if (!isset($this->response)) { |
|
| 53 | 1 | throw new \LogicException("Response not set, the controller has not been invoked"); |
|
| 54 | } |
||
| 55 | |||
| 56 | 2 | return $this->response; |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Get response. set for controller |
||
| 61 | * |
||
| 62 | * @return ResponseInterface |
||
| 63 | */ |
||
| 64 | 1 | public function setResponse(ResponseInterface $response) |
|
| 65 | { |
||
| 66 | 1 | $this->response = $response; |
|
| 67 | 1 | } |
|
| 68 | |||
| 69 | /** |
||
| 70 | * Run the controller |
||
| 71 | * |
||
| 72 | * @return ResponseInterface |
||
| 73 | */ |
||
| 74 | abstract public function run(); |
||
| 75 | |||
| 76 | |||
| 77 | /** |
||
| 78 | * Run the controller as function |
||
| 79 | * |
||
| 80 | * @param ServerRequestInterface $request |
||
| 81 | * @param ResponseInterface $response |
||
| 82 | * @return ResponseInterface |
||
| 83 | */ |
||
| 84 | 2 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response) |
|
| 85 | { |
||
| 86 | 2 | $this->request = $request; |
|
| 87 | 2 | $this->response = $response; |
|
| 88 | |||
| 89 | 2 | if (method_exists($this, 'useSession')) { |
|
| 90 | 1 | $this->useSession(); |
|
|
1 ignored issue
–
show
|
|||
| 91 | 1 | } |
|
| 92 | |||
| 93 | 2 | $this->run(); |
|
| 94 | |||
| 95 | 2 | return $this->getResponse(); |
|
| 96 | } |
||
| 97 | } |
||
| 98 |
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.