bytic /
http
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Nip\Http\Request\Traits; |
||||
| 4 | |||||
| 5 | /** |
||||
| 6 | * Trait HasInterface |
||||
| 7 | * @package Nip\Http\Request\Traits |
||||
| 8 | */ |
||||
| 9 | trait HasInterface |
||||
| 10 | { |
||||
| 11 | /** |
||||
| 12 | * Get the input source for the request. |
||||
| 13 | * |
||||
| 14 | * @return \Symfony\Component\HttpFoundation\ParameterBag |
||||
| 15 | */ |
||||
| 16 | 1 | protected function getInputSource() |
|||
| 17 | { |
||||
| 18 | 1 | if ($this->isJson()) { |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 19 | return $this->json(); |
||||
|
0 ignored issues
–
show
It seems like
json() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 20 | } |
||||
| 21 | |||||
| 22 | 1 | return in_array($this->getRealMethod(), ['GET', 'HEAD']) ? $this->query : $this->request; |
|||
|
0 ignored issues
–
show
It seems like
getRealMethod() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 23 | } |
||||
| 24 | |||||
| 25 | /** |
||||
| 26 | * @return bool |
||||
| 27 | */ |
||||
| 28 | public function isCLI() |
||||
| 29 | { |
||||
| 30 | if (defined('STDIN')) { |
||||
| 31 | return true; |
||||
| 32 | } |
||||
| 33 | |||||
| 34 | if (php_sapi_name() === 'cli') { |
||||
| 35 | return true; |
||||
| 36 | } |
||||
| 37 | |||||
| 38 | if (array_key_exists('SHELL', $_ENV)) { |
||||
| 39 | return true; |
||||
| 40 | } |
||||
| 41 | |||||
| 42 | if (empty($_SERVER['REMOTE_ADDR']) and !isset($_SERVER['HTTP_USER_AGENT']) and count($_SERVER['argv']) > 0) { |
||||
| 43 | return true; |
||||
| 44 | } |
||||
| 45 | |||||
| 46 | if (!array_key_exists('REQUEST_METHOD', $_SERVER)) { |
||||
| 47 | return true; |
||||
| 48 | } |
||||
| 49 | |||||
| 50 | return false; |
||||
| 51 | } |
||||
| 52 | |||||
| 53 | /** |
||||
| 54 | * Determine if the request is the result of an AJAX call. |
||||
| 55 | * |
||||
| 56 | * @return bool |
||||
| 57 | */ |
||||
| 58 | public function ajax() |
||||
| 59 | { |
||||
| 60 | return $this->isXmlHttpRequest(); |
||||
|
0 ignored issues
–
show
It seems like
isXmlHttpRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 61 | } |
||||
| 62 | |||||
| 63 | /** |
||||
| 64 | * Determine if the request is the result of an PJAX call. |
||||
| 65 | * |
||||
| 66 | * @return bool |
||||
| 67 | */ |
||||
| 68 | public function pjax() |
||||
| 69 | { |
||||
| 70 | return $this->headers->get('X-PJAX') == true; |
||||
| 71 | } |
||||
| 72 | } |
||||
| 73 |