| Total Complexity | 9 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 4 | abstract class AbstractSecurity |
||
| 5 | { |
||
| 6 | protected $request; |
||
| 7 | |||
| 8 | public function __construct(\WebServCo\Framework\Interfaces\RequestInterface $request) |
||
| 9 | { |
||
| 10 | $this->request = $request; |
||
| 11 | } |
||
| 12 | |||
| 13 | public function verify() |
||
| 14 | { |
||
| 15 | $this->verifySsl(); |
||
| 16 | $this->verifyMethod(); |
||
| 17 | $this->verifyContentType(); |
||
| 18 | } |
||
| 19 | |||
| 20 | abstract protected function getSupportedContentTypes(); |
||
| 21 | |||
| 22 | abstract protected function getAllowedMethods(); |
||
| 23 | |||
| 24 | abstract public function verifyAuthorization(); |
||
| 25 | |||
| 26 | protected function verifyContentType() |
||
| 27 | { |
||
| 28 | $clientContentTypes = $this->request->getAcceptContentTypes(); |
||
|
|
|||
| 29 | if (array_key_exists(0, $clientContentTypes)) { |
||
| 30 | unset($clientContentTypes[0]); // $q == 0 means, that mime-type isn’t supported! |
||
| 31 | } |
||
| 32 | $supportedContentTypes = $this->getSupportedContentTypes(); |
||
| 33 | $intersection = array_intersect($clientContentTypes, $supportedContentTypes); |
||
| 34 | if (empty($intersection)) { |
||
| 35 | throw new \WebServCo\Framework\Exceptions\UnsupportedMediaTypeException('Unsupported content type'); |
||
| 36 | } |
||
| 37 | return true; |
||
| 38 | } |
||
| 39 | |||
| 40 | protected function verifyMethod() |
||
| 41 | { |
||
| 42 | if (!in_array($this->request->getMethod(), $this->getAllowedMethods())) { |
||
| 43 | throw new \WebServCo\Framework\Exceptions\MethodNotAllowedException('Unsupported method'); |
||
| 44 | } |
||
| 45 | return true; |
||
| 46 | } |
||
| 47 | |||
| 48 | protected function verifySsl() |
||
| 55 | } |
||
| 56 | } |
||
| 57 |
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.