| Total Complexity | 9 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | trait CheckRequest |
||
| 12 | { |
||
| 13 | abstract protected function getRequest(): ServerRequestInterface; |
||
| 14 | |||
| 15 | |||
| 16 | /** |
||
| 17 | * Check if request is GET request |
||
| 18 | */ |
||
| 19 | protected function isGetRequest(): bool |
||
| 20 | { |
||
| 21 | return $this->getRequest()->getMethod() === 'GET' || $this->getRequest()->getMethod() === ''; |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Check if request is POST request |
||
| 26 | */ |
||
| 27 | protected function isPostRequest(): bool |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Check if request is PUT request |
||
| 34 | */ |
||
| 35 | protected function isPutRequest(): bool |
||
| 36 | { |
||
| 37 | return $this->getRequest()->getMethod() === 'PUT'; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Check if request is DELETE request |
||
| 42 | */ |
||
| 43 | protected function isDeleteRequest(): bool |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Check if request is HEAD request |
||
| 50 | */ |
||
| 51 | protected function isHeadRequest(): bool |
||
| 52 | { |
||
| 53 | return $this->getRequest()->getMethod() === 'HEAD'; |
||
| 54 | } |
||
| 55 | |||
| 56 | |||
| 57 | /** |
||
| 58 | * Returns the HTTP referer if it is on the current host |
||
| 59 | */ |
||
| 60 | protected function getLocalReferer(): ?string |
||
| 67 | } |
||
| 68 | } |
||
| 69 |