1 | <?php |
||
23 | class Request implements RequestData |
||
24 | { |
||
25 | /** |
||
26 | * @var array The get variables |
||
27 | */ |
||
28 | private $getVariables = []; |
||
29 | |||
30 | /** |
||
31 | * @var array The post variables |
||
32 | */ |
||
33 | private $postVariables = []; |
||
34 | |||
35 | /** |
||
36 | * @var array The server variables |
||
37 | */ |
||
38 | private $serverVariables = []; |
||
39 | |||
40 | /** |
||
41 | * @var array The path variables |
||
42 | */ |
||
43 | private $pathVariables = []; |
||
44 | |||
45 | /** |
||
46 | * Creates instance |
||
47 | * |
||
48 | * @param array $get The get variables |
||
49 | * @param array $post The post variables |
||
50 | * @param array $server The server variables |
||
51 | */ |
||
52 | 14 | public function __construct(array $get, array $post, array $server) |
|
59 | |||
60 | /** |
||
61 | * Gets the variable or returns false when it does not exists |
||
62 | * |
||
63 | * @return string The value of the get param or false when it does not exist |
||
64 | */ |
||
65 | 2 | public function get() |
|
75 | |||
76 | /** |
||
77 | * Gets the variable |
||
78 | * |
||
79 | * @return string The value of the path param |
||
80 | */ |
||
81 | 5 | public function path() |
|
85 | |||
86 | /** |
||
87 | * Gets the verb of the request |
||
88 | * |
||
89 | * @return string The verb used by the request |
||
90 | */ |
||
91 | 1 | public function getVerb() |
|
95 | |||
96 | /** |
||
97 | * Gets a post variable |
||
98 | * |
||
99 | * @param string $name The name of the post variable to get |
||
100 | * |
||
101 | * @return mixed The value |
||
102 | */ |
||
103 | 1 | public function post($name) |
|
107 | |||
108 | /** |
||
109 | * Gets the current URL |
||
110 | * |
||
111 | * @return string The current URL |
||
112 | */ |
||
113 | 3 | public function getUrl() |
|
114 | { |
||
115 | 3 | $scheme = 'http'; |
|
116 | |||
117 | 3 | if (isset($this->serverVariables['HTTPS']) && $this->serverVariables['HTTPS'] === 'on') { |
|
118 | 1 | $scheme .= 's'; |
|
119 | } |
||
120 | |||
121 | 3 | return $scheme . '://' . $this->serverVariables['HTTP_HOST'] . $this->serverVariables['REQUEST_URI']; |
|
122 | } |
||
123 | |||
124 | /** |
||
125 | * Gets the user's IP address |
||
126 | * |
||
127 | * @return string The IP of the user |
||
128 | */ |
||
129 | 1 | public function getIp() |
|
133 | } |
||
134 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.