@@ -85,7 +85,7 @@ |
||
85 | 85 | if ($characterDeficit == 0) { |
86 | 86 | //If the word is full and we're not short any characters, ignore the character |
87 | 87 | continue; |
88 | - }else |
|
88 | + } else |
|
89 | 89 | $characterDeficit--; //If we are short some characters, decrement the defecit and carry on with adding the character to the abbreviation |
90 | 90 | } |
91 | 91 | $abbreviation .= $currentChar; //Add the character to the abbreviation |
@@ -85,8 +85,10 @@ |
||
85 | 85 | if ($characterDeficit == 0) { |
86 | 86 | //If the word is full and we're not short any characters, ignore the character |
87 | 87 | continue; |
88 | - }else |
|
89 | - $characterDeficit--; //If we are short some characters, decrement the defecit and carry on with adding the character to the abbreviation |
|
88 | + } else { |
|
89 | + $characterDeficit--; |
|
90 | + } |
|
91 | + //If we are short some characters, decrement the defecit and carry on with adding the character to the abbreviation |
|
90 | 92 | } |
91 | 93 | $abbreviation .= $currentChar; //Add the character to the abbreviation |
92 | 94 | $abbrevLength++; //Increment abbreviation length |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | */ |
13 | 13 | private $invalidMiddleware; |
14 | 14 | |
15 | - public function __construct( $invalidMiddleware = null, $code = 0, Throwable $previous = null ) |
|
15 | + public function __construct($invalidMiddleware = null, $code = 0, Throwable $previous = null) |
|
16 | 16 | { |
17 | 17 | $message = \sprintf(self::ERROR_MESSAGE, MiddlewareInterface::class, $this->castStageToString($invalidMiddleware)); |
18 | - parent::__construct( $message, $code, $previous); |
|
18 | + parent::__construct($message, $code, $previous); |
|
19 | 19 | $this->invalidMiddleware = $invalidMiddleware; |
20 | 20 | } |
21 | 21 | |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | * return the invalid middleware |
24 | 24 | * @return mixed|null |
25 | 25 | */ |
26 | - public function getInvalidMiddleware(){ |
|
26 | + public function getInvalidMiddleware() { |
|
27 | 27 | return $this->invalidMiddleware; |
28 | 28 | } |
29 | 29 | private function castStageToString(string $stage) : string{ |
30 | 30 | |
31 | - if(\is_scalar($stage)){ |
|
32 | - return (string) $stage; |
|
31 | + if (\is_scalar($stage)) { |
|
32 | + return (string)$stage; |
|
33 | 33 | } |
34 | 34 | |
35 | - if(\is_scalar($stage)){ |
|
35 | + if (\is_scalar($stage)) { |
|
36 | 36 | return \json_encode($stage) ?: 'array'; |
37 | 37 | } |
38 | 38 | |
39 | - if(\is_object($stage)){ |
|
39 | + if (\is_object($stage)) { |
|
40 | 40 | return \get_class($stage) ?: 'array'; |
41 | 41 | } |
42 | 42 |
@@ -125,8 +125,8 @@ |
||
125 | 125 | * |
126 | 126 | * O URL base do sistema |
127 | 127 | */ |
128 | -$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST']; |
|
129 | -$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); |
|
128 | +$root = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST']; |
|
129 | +$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); |
|
130 | 130 | |
131 | 131 | define('URL', $root); |
132 | 132 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | if (is_string($body) || null === $body) { |
62 | 62 | $stream = fopen('php://temp', 'r+'); |
63 | - fwrite($stream, (string) $body); |
|
63 | + fwrite($stream, (string)$body); |
|
64 | 64 | rewind($stream); |
65 | 65 | |
66 | 66 | return $stream; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | $contentLength = $this->getHeader('Content-Length'); |
97 | 97 | if (is_int($contentLength) || ctype_digit($contentLength)) { |
98 | - return stream_get_contents($body, (int) $contentLength); |
|
98 | + return stream_get_contents($body, (int)$contentLength); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return stream_get_contents($body); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function setHeader(string $name, $value) |
206 | 206 | { |
207 | - $this->headers[strtolower($name)] = [$name, (array) $value]; |
|
207 | + $this->headers[strtolower($name)] = [$name, (array)$value]; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | if (isset($this->headers[$lName])) { |
238 | 238 | $this->headers[$lName][1] = array_merge( |
239 | 239 | $this->headers[$lName][1], |
240 | - (array) $value |
|
240 | + (array)$value |
|
241 | 241 | ); |
242 | 242 | } else { |
243 | 243 | $this->headers[$lName] = [ |
244 | 244 | $name, |
245 | - (array) $value, |
|
245 | + (array)$value, |
|
246 | 246 | ]; |
247 | 247 | } |
248 | 248 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $statusCode, |
167 | 167 | $statusText |
168 | 168 | ) = explode(' ', $status, 2); |
169 | - $statusCode = (int) $statusCode; |
|
169 | + $statusCode = (int)$statusCode; |
|
170 | 170 | } |
171 | 171 | if ($statusCode < 100 || $statusCode > 999) { |
172 | 172 | throw new \InvalidArgumentException('The HTTP status code must be exactly 3 digits'); |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function __toString(): string |
185 | 185 | { |
186 | - $str = 'HTTP/'.$this->httpVersion.' '.$this->getStatus().' '.$this->getStatusText()."\r\n"; |
|
186 | + $str = 'HTTP/' . $this->httpVersion . ' ' . $this->getStatus() . ' ' . $this->getStatusText() . "\r\n"; |
|
187 | 187 | foreach ($this->getHeaders() as $key => $value) { |
188 | 188 | foreach ($value as $v) { |
189 | - $str .= $key.': '.$v."\r\n"; |
|
189 | + $str .= $key . ': ' . $v . "\r\n"; |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | $str .= "\r\n"; |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | { |
115 | 115 | if (!$this->absoluteUrl) { |
116 | 116 | // Guessing we're a http endpoint. |
117 | - $this->absoluteUrl = 'http://'. |
|
118 | - ($this->getHeader('Host') ?? 'localhost'). |
|
117 | + $this->absoluteUrl = 'http://' . |
|
118 | + ($this->getHeader('Host') ?? 'localhost') . |
|
119 | 119 | $this->getUrl(); |
120 | 120 | } |
121 | 121 | |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | return trim(substr($uri, strlen($baseUri)), '/'); |
178 | 178 | } |
179 | 179 | |
180 | - if ($uri.'/' === $baseUri) { |
|
180 | + if ($uri . '/' === $baseUri) { |
|
181 | 181 | return ''; |
182 | 182 | } |
183 | 183 | // A special case, if the baseUri was accessed without a trailing |
184 | 184 | // slash, we'll accept it as well. |
185 | 185 | |
186 | - throw new \LogicException('Requested uri ('.$this->getUrl().') is out of base uri ('.$this->getBaseUrl().')'); |
|
186 | + throw new \LogicException('Requested uri (' . $this->getUrl() . ') is out of base uri (' . $this->getBaseUrl() . ')'); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function __toString(): string |
252 | 252 | { |
253 | - $out = $this->getMethod().' '.$this->getUrl().' HTTP/'.$this->getHttpVersion()."\r\n"; |
|
253 | + $out = $this->getMethod() . ' ' . $this->getUrl() . ' HTTP/' . $this->getHttpVersion() . "\r\n"; |
|
254 | 254 | |
255 | 255 | foreach ($this->getHeaders() as $key => $value) { |
256 | 256 | foreach ($value as $v) { |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | list($v) = explode(' ', $v, 2); |
259 | 259 | $v .= ' REDACTED'; |
260 | 260 | } |
261 | - $out .= $key.': '.$v."\r\n"; |
|
261 | + $out .= $key . ': ' . $v . "\r\n"; |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | $out .= "\r\n"; |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | if (!empty($currentRoute)) { |
342 | 342 | $currentRoute = current($currentRoute); |
343 | 343 | $foundRoute = true; |
344 | - $this->runRouteMiddleware($currentRoute, 'before', $this->request, $this->response); |
|
344 | + $this->runRouteMiddleware($currentRoute, 'before', $this->request, $this->response); |
|
345 | 345 | $this->runRouteCommand($currentRoute['callback']); |
346 | - $this->runRouteMiddleware($currentRoute, 'after', $this->request, $this->response); |
|
346 | + $this->runRouteMiddleware($currentRoute, 'after', $this->request, $this->response); |
|
347 | 347 | } |
348 | 348 | } else { |
349 | 349 | foreach ($this->routes as $data) { |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | if ($this->request->validMethod($data['method'], $method)) { |
357 | 357 | $foundRoute = true; |
358 | 358 | |
359 | - $this->runRouteMiddleware($data, 'before', $this->request, $this->response); |
|
359 | + $this->runRouteMiddleware($data, 'before', $this->request, $this->response); |
|
360 | 360 | |
361 | 361 | array_shift($matched); |
362 | 362 | $matched = array_map(function($value) { |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | }, $matched); |
365 | 365 | |
366 | 366 | $this->runRouteCommand($data['callback'], $matched, $this->request); |
367 | - $this->runRouteMiddleware($data, 'after', $this->request, $this->response); |
|
367 | + $this->runRouteMiddleware($data, 'after', $this->request, $this->response); |
|
368 | 368 | break; |
369 | 369 | } |
370 | 370 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return bool |
398 | 398 | */ |
399 | - public function group($settings = null, $callback = null, $name =null) |
|
399 | + public function group($settings = null, $callback = null, $name = null) |
|
400 | 400 | { |
401 | 401 | if ($this->cacheLoaded) { |
402 | 402 | return true; |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | $this->criateRoute($route, $groupItem, $method, $callback, $settings); |
557 | 557 | } |
558 | 558 | |
559 | - private function criateRoute($route, $groupItem, $method, $callback, $settings){ |
|
559 | + private function criateRoute($route, $groupItem, $method, $callback, $settings) { |
|
560 | 560 | $routeName = is_string($callback) |
561 | 561 | ? strtolower(preg_replace( |
562 | 562 | '/[^\w]/i', '/', str_replace($this->namespaces['controllers'], '', $callback) |
@@ -112,7 +112,7 @@ |
||
112 | 112 | |
113 | 113 | $this->explode = explode('.', $this->name); |
114 | 114 | } |
115 | - }else { |
|
115 | + } else { |
|
116 | 116 | $this->name = $_FILES[$filename]['name']; |
117 | 117 | $this->size = $_FILES[$filename]['size']; |
118 | 118 | $this->type = $_FILES[$filename]['type']; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | public function __construct(ResizeInterface $image, string $filename = 'archive') |
104 | 104 | { |
105 | 105 | if (!empty($_FILES[$filename])) { |
106 | - if(is_array( $_FILES[$filename]['name'])){ |
|
106 | + if (is_array($_FILES[$filename]['name'])) { |
|
107 | 107 | foreach ($_FILES[$filename]['name'] as $i => $name) { |
108 | 108 | $this->name = $_FILES[$filename]['name'][$i]; |
109 | 109 | $this->size = $_FILES[$filename]['size'][$i]; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | $this->explode = explode('.', $this->name); |
114 | 114 | } |
115 | - }else { |
|
115 | + } else { |
|
116 | 116 | $this->name = $_FILES[$filename]['name']; |
117 | 117 | $this->size = $_FILES[$filename]['size']; |
118 | 118 | $this->type = $_FILES[$filename]['type']; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * make PathDir If User Exist |
133 | 133 | * @param string $userNamePath |
134 | 134 | */ |
135 | - public function file($dir_name = null, $userNamePath= null) |
|
135 | + public function file($dir_name = null, $userNamePath = null) |
|
136 | 136 | { |
137 | 137 | $this->dir = $dir_name; |
138 | 138 | $this->userNamePath = $userNamePath; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | private function make() |
147 | 147 | { |
148 | - if ( null == $this->userNamePath ) { |
|
148 | + if (null == $this->userNamePath) { |
|
149 | 149 | $this->makeDefaultPath(); |
150 | 150 | $this->makePathDirIfDefaultFileNotExist(); |
151 | 151 | return $this->moveUploadedFile(); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | private function makePathBayUserName(): String |
210 | 210 | { |
211 | 211 | $this->ext = end($this->explode); |
212 | - $this->path = DIR_FILE . 'Upload' . DS. $this->userNamePath . DS . $this->dir . DS; |
|
212 | + $this->path = DIR_FILE . 'Upload' . DS . $this->userNamePath . DS . $this->dir . DS; |
|
213 | 213 | $this->path .= basename($this->explode[0] . time() . '.' . $this->ext); |
214 | 214 | |
215 | 215 | return $this->path; |
@@ -143,10 +143,10 @@ |
||
143 | 143 | return $headers; |
144 | 144 | } |
145 | 145 | |
146 | - /** |
|
147 | - * This static method will create a new Request object, based on the |
|
148 | - * current PHP request. |
|
149 | - */ |
|
146 | + /** |
|
147 | + * This static method will create a new Request object, based on the |
|
148 | + * current PHP request. |
|
149 | + */ |
|
150 | 150 | public static function getRequest(): RequestBuilder |
151 | 151 | { |
152 | 152 | $serverArr = $_SERVER; |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public static function sendResponse(Response $response) : Response |
168 | 168 | { |
169 | - header('HTTP/'.$response->getHttpVersion().' '.$response->getStatus().' '.$response->getStatusText()); |
|
169 | + header('HTTP/' . $response->getHttpVersion() . ' ' . $response->getStatus() . ' ' . $response->getStatusText()); |
|
170 | 170 | foreach ($response->getHeaders() as $key => $value) { |
171 | 171 | foreach ($value as $k => $v) { |
172 | 172 | if (0 === $k) { |
173 | - header($key.': '.$v); |
|
173 | + header($key . ': ' . $v); |
|
174 | 174 | } else { |
175 | - header($key.': '.$v, false); |
|
175 | + header($key . ': ' . $v, false); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
@@ -225,13 +225,13 @@ discard block |
||
225 | 225 | // (fast)cgi does not usually do this, however. |
226 | 226 | case 'PHP_AUTH_USER': |
227 | 227 | if (isset($serverArray['PHP_AUTH_PW'])) { |
228 | - $headers['Authorization'] = 'Basic '.base64_encode($value.':'.$serverArray['PHP_AUTH_PW']); |
|
228 | + $headers['Authorization'] = 'Basic ' . base64_encode($value . ':' . $serverArray['PHP_AUTH_PW']); |
|
229 | 229 | } |
230 | 230 | break; |
231 | 231 | |
232 | 232 | // Similarly, mod_php may also screw around with digest auth. |
233 | 233 | case 'PHP_AUTH_DIGEST': |
234 | - $headers['Authorization'] = 'Digest '.$value; |
|
234 | + $headers['Authorization'] = 'Digest ' . $value; |
|
235 | 235 | break; |
236 | 236 | |
237 | 237 | // Apache may prefix the HTTP_AUTHORIZATION header with |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $r = new RequestBuilder($method, $url, $headers); |
281 | 281 | $r->setHttpVersion($httpVersion); |
282 | 282 | $r->setRawServerData($serverArray); |
283 | - $r->setAbsoluteUrl($protocol.'://'.$hostName.$url); |
|
283 | + $r->setAbsoluteUrl($protocol . '://' . $hostName . $url); |
|
284 | 284 | |
285 | 285 | return $r; |
286 | 286 | } |