6
6
use MaplePHP \Http \Interfaces \UriInterface ;
7
7
use MaplePHP \Http \Interfaces \HeadersInterface ;
8
8
use MaplePHP \Http \Interfaces \StreamInterface ;
9
- use MaplePHP \Http \Uri ;
10
9
11
10
class Request extends Message implements RequestInterface
12
11
{
@@ -119,8 +118,7 @@ public function isSSL(): bool
119
118
public function getPort (): int
120
119
{
121
120
$ serverPort = $ this ->env ->get ("SERVER_PORT " );
122
- $ port = (int )(($ serverPort ) ? $ serverPort : $ this ->uri ->getPort ());
123
- return $ port ;
121
+ return (int )(($ serverPort ) ? $ serverPort : $ this ->uri ->getPort ());
124
122
}
125
123
126
124
/**
@@ -135,7 +133,7 @@ final protected function setHostHeader(): void
135
133
}
136
134
137
135
/**
138
- * This will resolve the Request Stream and make the call user friendly
136
+ * This will resolve the Request Stream and make the call user- friendly
139
137
* @param StreamInterface|array|string|null $body
140
138
* @return StreamInterface
141
139
*/
@@ -156,18 +154,18 @@ private function resolveRequestStream(StreamInterface|array|string|null $body):
156
154
return $ stream ;
157
155
}
158
156
159
- /**
160
- * Get Cli keyword
161
- * @return string|null
162
- */
157
+ /**
158
+ * Get Cli keyword
159
+ * @return string|null
160
+ */
163
161
public function getCliKeyword (): ?string
164
162
{
165
163
if (is_null ($ this ->cliKeywords )) {
166
- $ new = array () ;
164
+ $ new = [] ;
167
165
$ arg = $ this ->getUri ()->getArgv ();
168
166
foreach ($ arg as $ val ) {
169
167
if (is_string ($ val )) {
170
- if ((strpos ($ val , "-- " ) === 0 ) || (strpos ($ val , "- " ) === 0 )) {
168
+ if ((str_starts_with ($ val , "-- " )) || (str_starts_with ($ val , "- " ))) {
171
169
break ;
172
170
} else {
173
171
$ new [] = $ val ;
@@ -189,11 +187,11 @@ public function getCliArgs(): array
189
187
{
190
188
if (is_null ($ this ->cliArgs )) {
191
189
$ args = $ this ->getUri ()->getArgv ();
192
- $ this ->cliArgs = array () ;
190
+ $ this ->cliArgs = [] ;
193
191
foreach ($ args as $ arg ) {
194
192
if (is_string ($ arg )) {
195
193
$ arg = str_replace ("& " , "# " , $ arg );
196
- if ((($ pos1 = strpos ($ arg , "-- " )) === 0 ) || (strpos ($ arg , "- " ) === 0 )) {
194
+ if ((($ pos1 = strpos ($ arg , "-- " )) === 0 ) || (str_starts_with ($ arg , "- " ))) {
197
195
parse_str (substr ($ arg , ($ pos1 !== false ? 2 : 1 )), $ result );
198
196
foreach ($ result as &$ val ) {
199
197
$ val = str_replace ("# " , "& " , $ val );
0 commit comments