@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @access public |
| 155 | 155 | * @param mixed $parser |
| 156 | 156 | */ |
| 157 | - public function __construct($parser) |
|
| 157 | + public function __construct ($parser) |
|
| 158 | 158 | { |
| 159 | 159 | $this->parser = $parser ?: new StdParser; |
| 160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param Dispatcher $dispatcher |
| 167 | 167 | * @return Router |
| 168 | 168 | */ |
| 169 | - public function setDispatcher(Dispatcher $dispatcher) |
|
| 169 | + public function setDispatcher (Dispatcher $dispatcher) |
|
| 170 | 170 | { |
| 171 | 171 | $this->dispatcher = $dispatcher; |
| 172 | 172 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param CacheInterface $cacheEngine |
| 181 | 181 | * @return Router |
| 182 | 182 | */ |
| 183 | - public function setCacheEngine(CacheInterface $cacheEngine) |
|
| 183 | + public function setCacheEngine (CacheInterface $cacheEngine) |
|
| 184 | 184 | { |
| 185 | 185 | $this->cacheEngine = $cacheEngine; |
| 186 | 186 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param int $cacheTtl |
| 195 | 195 | * @return Router |
| 196 | 196 | */ |
| 197 | - public function setCacheTtl(int $cacheTtl) |
|
| 197 | + public function setCacheTtl (int $cacheTtl) |
|
| 198 | 198 | { |
| 199 | 199 | $this->cacheTtl = $cacheTtl; |
| 200 | 200 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param string $cacheKey |
| 209 | 209 | * @return Router |
| 210 | 210 | */ |
| 211 | - public function setCacheKey(string $cacheKey) |
|
| 211 | + public function setCacheKey (string $cacheKey) |
|
| 212 | 212 | { |
| 213 | 213 | $this->cacheKey = $cacheKey; |
| 214 | 214 | return $this; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @param string $identifier |
| 222 | 222 | * @return null|Route |
| 223 | 223 | */ |
| 224 | - public function getRoute(string $identifier) |
|
| 224 | + public function getRoute (string $identifier) |
|
| 225 | 225 | { |
| 226 | 226 | return !empty($this->routes[$identifier]) ? $this->routes[$identifier] : null; |
| 227 | 227 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @access public |
| 233 | 233 | * @return array |
| 234 | 234 | */ |
| 235 | - public function getRoutes() |
|
| 235 | + public function getRoutes () |
|
| 236 | 236 | { |
| 237 | 237 | return $this->routes; |
| 238 | 238 | } |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | * @param array $routes |
| 246 | 246 | * @return Router |
| 247 | 247 | */ |
| 248 | - public function setRoutes(array $method, array $routes) |
|
| 248 | + public function setRoutes (array $method, array $routes) |
|
| 249 | 249 | { |
| 250 | 250 | foreach ($routes as $pattern => $handler) { |
| 251 | - $this->map($method, $pattern, $handler); |
|
| 251 | + $this->map ($method, $pattern, $handler); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $this; |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @access public |
| 261 | 261 | * @return void |
| 262 | 262 | */ |
| 263 | - public function getResult() |
|
| 263 | + public function getResult () |
|
| 264 | 264 | { |
| 265 | 265 | return $this->dispatch_result; |
| 266 | 266 | } |
@@ -268,19 +268,19 @@ discard block |
||
| 268 | 268 | /** |
| 269 | 269 | * {@inheritdoc} |
| 270 | 270 | */ |
| 271 | - public function map($method, string $pattern, $handler) |
|
| 271 | + public function map ($method, string $pattern, $handler) |
|
| 272 | 272 | { |
| 273 | - $method = is_array($method) ? $method : [$method]; |
|
| 273 | + $method = is_array ($method) ? $method : [$method]; |
|
| 274 | 274 | |
| 275 | 275 | foreach ($method as $m) { |
| 276 | - $route = $this->createRoute($m, $pattern, $handler); |
|
| 276 | + $route = $this->createRoute ($m, $pattern, $handler); |
|
| 277 | 277 | |
| 278 | 278 | $this->routeCount++; |
| 279 | 279 | |
| 280 | - $this->routes[$route->getIdentifier()] = $route; |
|
| 280 | + $this->routes[$route->getIdentifier ()] = $route; |
|
| 281 | 281 | |
| 282 | - if (is_callable($handler)) { |
|
| 283 | - $route->bind('run', $handler); |
|
| 282 | + if (is_callable ($handler)) { |
|
| 283 | + $route->bind ('run', $handler); |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | * @param mixed $handler |
| 297 | 297 | * @return Route Route |
| 298 | 298 | */ |
| 299 | - protected function createRoute(string $method, string $pattern, $handler) |
|
| 299 | + protected function createRoute (string $method, string $pattern, $handler) |
|
| 300 | 300 | { |
| 301 | - return new Route($method, $pattern, $handler, $this->routeGroup, 'route_' . $this->routeCount); |
|
| 301 | + return new Route ($method, $pattern, $handler, $this->routeGroup, 'route_' . $this->routeCount); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @param array $options (default: []) |
| 310 | 310 | * @return Dispatcher |
| 311 | 311 | */ |
| 312 | - protected function routeDispatcher(callable $routeDefinitionCallback, array $options = []) |
|
| 312 | + protected function routeDispatcher (callable $routeDefinitionCallback, array $options = []) |
|
| 313 | 313 | { |
| 314 | 314 | $options += [ |
| 315 | 315 | 'routeParser' => 'FastRoute\\RouteParser\\Std', |
@@ -322,24 +322,24 @@ discard block |
||
| 322 | 322 | $routeCollector = new $options['routeCollector']( |
| 323 | 323 | new $options['routeParser'], new $options['dataGenerator'] |
| 324 | 324 | ); |
| 325 | - $routeDefinitionCallback($routeCollector); |
|
| 325 | + $routeDefinitionCallback ($routeCollector); |
|
| 326 | 326 | |
| 327 | - return $routeCollector->getData(); |
|
| 327 | + return $routeCollector->getData (); |
|
| 328 | 328 | }; |
| 329 | 329 | |
| 330 | 330 | if (!empty($this->cacheEngine) && !empty($this->cacheKey)) { |
| 331 | - if ($this->cacheEngine->has($this->cacheKey)) { |
|
| 332 | - $dispatchData = $this->cacheEngine->get($this->cacheKey); |
|
| 331 | + if ($this->cacheEngine->has ($this->cacheKey)) { |
|
| 332 | + $dispatchData = $this->cacheEngine->get ($this->cacheKey); |
|
| 333 | 333 | |
| 334 | 334 | return new $options['dispatcher']($dispatchData); |
| 335 | 335 | } else { |
| 336 | - $dispatchData = $dispatchDataRunner(); |
|
| 337 | - $this->cacheEngine->set($this->cacheKey, $dispatchData, $this->cacheTtl); |
|
| 336 | + $dispatchData = $dispatchDataRunner (); |
|
| 337 | + $this->cacheEngine->set ($this->cacheKey, $dispatchData, $this->cacheTtl); |
|
| 338 | 338 | |
| 339 | 339 | return $dispatchData; |
| 340 | 340 | } |
| 341 | 341 | } else { |
| 342 | - return new $options['dispatcher']($dispatchDataRunner()); |
|
| 342 | + return new $options['dispatcher']($dispatchDataRunner ()); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | } |
@@ -350,19 +350,19 @@ discard block |
||
| 350 | 350 | * @access protected |
| 351 | 351 | * @return Dispatcher |
| 352 | 352 | */ |
| 353 | - protected function createDispatcher() |
|
| 353 | + protected function createDispatcher () |
|
| 354 | 354 | { |
| 355 | 355 | if ($this->dispatcher) { |
| 356 | 356 | return $this->dispatcher; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | $routeDefinitionCallback = function (RouteCollector $r) { |
| 360 | - foreach ($this->getRoutes() as $route) { |
|
| 361 | - $r->addRoute($route->getMethod(), $route->getPattern(), $route->getIdentifier()); |
|
| 360 | + foreach ($this->getRoutes () as $route) { |
|
| 361 | + $r->addRoute ($route->getMethod (), $route->getPattern (), $route->getIdentifier ()); |
|
| 362 | 362 | } |
| 363 | 363 | }; |
| 364 | 364 | |
| 365 | - $this->dispatcher = $this->routeDispatcher($routeDefinitionCallback, [ |
|
| 365 | + $this->dispatcher = $this->routeDispatcher ($routeDefinitionCallback, [ |
|
| 366 | 366 | 'routeParser' => $this->parser, |
| 367 | 367 | ]); |
| 368 | 368 | |
@@ -377,22 +377,22 @@ discard block |
||
| 377 | 377 | * @param string $method (default: 'GET') |
| 378 | 378 | * @return Route Handling Method |
| 379 | 379 | */ |
| 380 | - public function dispatch(UriInterface $uri, $method = 'GET') |
|
| 380 | + public function dispatch (UriInterface $uri, $method = 'GET') |
|
| 381 | 381 | { |
| 382 | - $this->dispatch_result = $this->createDispatcher()->dispatch( |
|
| 382 | + $this->dispatch_result = $this->createDispatcher ()->dispatch ( |
|
| 383 | 383 | $method, |
| 384 | - $uri->getPath() |
|
| 384 | + $uri->getPath () |
|
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | 387 | $functionHandler = function ($arg) use ($uri, $method) { |
| 388 | - if (method_exists($this, $arg['methodName']) || $this->hasMethod($arg['methodName'])) { |
|
| 388 | + if (method_exists ($this, $arg['methodName']) || $this->hasMethod ($arg['methodName'])) { |
|
| 389 | 389 | return $this->{$arg['methodName']}(...$arg['args']); |
| 390 | 390 | } else { |
| 391 | - return $this->handleException($arg['methodName'], $uri, $method); |
|
| 391 | + return $this->handleException ($arg['methodName'], $uri, $method); |
|
| 392 | 392 | } |
| 393 | 393 | }; |
| 394 | 394 | |
| 395 | - $code = array_shift($this->dispatch_result); |
|
| 395 | + $code = array_shift ($this->dispatch_result); |
|
| 396 | 396 | |
| 397 | 397 | $handlerMapper = [ |
| 398 | 398 | Dispatcher::NOT_FOUND => [ |
@@ -409,17 +409,17 @@ discard block |
||
| 409 | 409 | ] |
| 410 | 410 | ]; |
| 411 | 411 | |
| 412 | - return $functionHandler($handlerMapper[$code]); |
|
| 412 | + return $functionHandler ($handlerMapper[$code]); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - protected function handleException($exception, $uri, $method) |
|
| 415 | + protected function handleException ($exception, $uri, $method) |
|
| 416 | 416 | { |
| 417 | 417 | if ($exception === $this->notFoundFuncName) { |
| 418 | - throw new BadMethodCallException('Method : ' . ((string) $method) . ' ON uri : ' . ((string) $uri) . ' Not Allowed'); |
|
| 418 | + throw new BadMethodCallException ('Method : ' . ((string) $method) . ' ON uri : ' . ((string) $uri) . ' Not Allowed'); |
|
| 419 | 419 | } elseif ($exception === $this->forbiddenFuncName) { |
| 420 | - throw new BadMethodCallException(((string) $uri) . ' Not Available'); |
|
| 420 | + throw new BadMethodCallException (((string) $uri) . ' Not Available'); |
|
| 421 | 421 | } else { |
| 422 | - throw new BadMethodCallException('There is no method or exception to handle this request ' . ((string) $uri)); |
|
| 422 | + throw new BadMethodCallException ('There is no method or exception to handle this request ' . ((string) $uri)); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | return null; |
@@ -432,9 +432,9 @@ discard block |
||
| 432 | 432 | * @param callable $callable |
| 433 | 433 | * @return Router |
| 434 | 434 | */ |
| 435 | - public function whenNotFound(callable $callable) |
|
| 435 | + public function whenNotFound (callable $callable) |
|
| 436 | 436 | { |
| 437 | - $this->bind($this->notFoundFuncName, $callable); |
|
| 437 | + $this->bind ($this->notFoundFuncName, $callable); |
|
| 438 | 438 | |
| 439 | 439 | return $this; |
| 440 | 440 | } |
@@ -446,9 +446,9 @@ discard block |
||
| 446 | 446 | * @param callable $callable |
| 447 | 447 | * @return Router |
| 448 | 448 | */ |
| 449 | - public function whenForbidden(callable $callable) |
|
| 449 | + public function whenForbidden (callable $callable) |
|
| 450 | 450 | { |
| 451 | - $this->bind($this->forbiddenFuncName, $callable); |
|
| 451 | + $this->bind ($this->forbiddenFuncName, $callable); |
|
| 452 | 452 | |
| 453 | 453 | return $this; |
| 454 | 454 | } |
@@ -461,20 +461,20 @@ discard block |
||
| 461 | 461 | * @param mixed $args |
| 462 | 462 | * @return void |
| 463 | 463 | */ |
| 464 | - protected function routerRoutine($identifier, $args) |
|
| 464 | + protected function routerRoutine ($identifier, $args) |
|
| 465 | 465 | { |
| 466 | - $route = $this->getRoute($identifier); |
|
| 466 | + $route = $this->getRoute ($identifier); |
|
| 467 | 467 | |
| 468 | 468 | if (!empty($args)) { |
| 469 | 469 | foreach ($args as &$v) { |
| 470 | - $v = urldecode($v); |
|
| 470 | + $v = urldecode ($v); |
|
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - if ($route->hasMethod('run')) { |
|
| 475 | - return $route->run($args); |
|
| 474 | + if ($route->hasMethod ('run')) { |
|
| 475 | + return $route->run ($args); |
|
| 476 | 476 | } else { |
| 477 | - return $route->setArgs($args); |
|
| 477 | + return $route->setArgs ($args); |
|
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param string $user Uri user. |
| 76 | 76 | * @param string $password Uri password. |
| 77 | 77 | */ |
| 78 | - public function __construct( |
|
| 78 | + public function __construct ( |
|
| 79 | 79 | $scheme, |
| 80 | 80 | $host, |
| 81 | 81 | $port = null, |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | $user = '', |
| 86 | 86 | $password = '' |
| 87 | 87 | ) { |
| 88 | - $this->scheme = $this->filterScheme($scheme); |
|
| 88 | + $this->scheme = $this->filterScheme ($scheme); |
|
| 89 | 89 | $this->host = $host; |
| 90 | - $this->port = $this->filterPort($port); |
|
| 91 | - $this->path = empty($path) ? '/' : $this->filterPath($path); |
|
| 92 | - $this->query = $this->filterQuery($query); |
|
| 93 | - $this->fragment = $this->filterQuery($fragment); |
|
| 90 | + $this->port = $this->filterPort ($port); |
|
| 91 | + $this->path = empty($path) ? '/' : $this->filterPath ($path); |
|
| 92 | + $this->query = $this->filterQuery ($query); |
|
| 93 | + $this->fragment = $this->filterQuery ($fragment); |
|
| 94 | 94 | $this->user = $user; |
| 95 | 95 | $this->password = $password; |
| 96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * {@inheritdoc} |
| 100 | 100 | */ |
| 101 | - public function getScheme() |
|
| 101 | + public function getScheme () |
|
| 102 | 102 | { |
| 103 | 103 | return $this->scheme; |
| 104 | 104 | } |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | /** |
| 107 | 107 | * {@inheritdoc} |
| 108 | 108 | */ |
| 109 | - public function getAuthority() |
|
| 109 | + public function getAuthority () |
|
| 110 | 110 | { |
| 111 | - $userInfo = $this->getUserInfo(); |
|
| 112 | - $host = $this->getHost(); |
|
| 113 | - $port = $this->getPort(); |
|
| 111 | + $userInfo = $this->getUserInfo (); |
|
| 112 | + $host = $this->getHost (); |
|
| 113 | + $port = $this->getPort (); |
|
| 114 | 114 | |
| 115 | 115 | return ($userInfo ? $userInfo . '@' : '') . $host . ($port !== null ? ':' . $port : ''); |
| 116 | 116 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | /** |
| 119 | 119 | * {@inheritdoc} |
| 120 | 120 | */ |
| 121 | - public function getUserInfo() |
|
| 121 | + public function getUserInfo () |
|
| 122 | 122 | { |
| 123 | 123 | return $this->user . ($this->password ? ':' . $this->password : ''); |
| 124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * {@inheritdoc} |
| 128 | 128 | */ |
| 129 | - public function getHost() |
|
| 129 | + public function getHost () |
|
| 130 | 130 | { |
| 131 | 131 | return $this->host; |
| 132 | 132 | } |
@@ -134,15 +134,15 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * {@inheritdoc} |
| 136 | 136 | */ |
| 137 | - public function getPort() |
|
| 137 | + public function getPort () |
|
| 138 | 138 | { |
| 139 | - return $this->port !== null && !$this->hasStandardPort() ? $this->port : null; |
|
| 139 | + return $this->port !== null && !$this->hasStandardPort () ? $this->port : null; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | 143 | * {@inheritdoc} |
| 144 | 144 | */ |
| 145 | - public function getPath() |
|
| 145 | + public function getPath () |
|
| 146 | 146 | { |
| 147 | 147 | return $this->path; |
| 148 | 148 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * {@inheritdoc} |
| 152 | 152 | */ |
| 153 | - public function getQuery() |
|
| 153 | + public function getQuery () |
|
| 154 | 154 | { |
| 155 | 155 | return $this->query; |
| 156 | 156 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | /** |
| 159 | 159 | * {@inheritdoc} |
| 160 | 160 | */ |
| 161 | - public function getFragment() |
|
| 161 | + public function getFragment () |
|
| 162 | 162 | { |
| 163 | 163 | return $this->fragment; |
| 164 | 164 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | /** |
| 167 | 167 | * {@inheritdoc} |
| 168 | 168 | */ |
| 169 | - public function withScheme($scheme) |
|
| 169 | + public function withScheme ($scheme) |
|
| 170 | 170 | { |
| 171 | - $scheme = $this->filterScheme($scheme); |
|
| 171 | + $scheme = $this->filterScheme ($scheme); |
|
| 172 | 172 | $clone = clone $this; |
| 173 | 173 | $clone->scheme = $scheme; |
| 174 | 174 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | /** |
| 179 | 179 | * {@inheritdoc} |
| 180 | 180 | */ |
| 181 | - public function withUserInfo($user, $password = null) |
|
| 181 | + public function withUserInfo ($user, $password = null) |
|
| 182 | 182 | { |
| 183 | 183 | $clone = clone $this; |
| 184 | 184 | $clone->user = $user; |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | /** |
| 191 | 191 | * {@inheritdoc} |
| 192 | 192 | */ |
| 193 | - public function withHost($host) |
|
| 193 | + public function withHost ($host) |
|
| 194 | 194 | { |
| 195 | 195 | $clone = clone $this; |
| 196 | 196 | $clone->host = $host; |
@@ -201,9 +201,9 @@ discard block |
||
| 201 | 201 | /** |
| 202 | 202 | * {@inheritdoc} |
| 203 | 203 | */ |
| 204 | - public function withPort($port) |
|
| 204 | + public function withPort ($port) |
|
| 205 | 205 | { |
| 206 | - $port = $this->filterPort($port); |
|
| 206 | + $port = $this->filterPort ($port); |
|
| 207 | 207 | $clone = clone $this; |
| 208 | 208 | $clone->port = $port; |
| 209 | 209 | |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | /** |
| 214 | 214 | * {@inheritdoc} |
| 215 | 215 | */ |
| 216 | - public function withPath($path) |
|
| 216 | + public function withPath ($path) |
|
| 217 | 217 | { |
| 218 | 218 | $clone = clone $this; |
| 219 | - $clone->path = $this->filterPath($path); |
|
| 219 | + $clone->path = $this->filterPath ($path); |
|
| 220 | 220 | |
| 221 | 221 | return $clone; |
| 222 | 222 | } |
@@ -224,17 +224,17 @@ discard block |
||
| 224 | 224 | /** |
| 225 | 225 | * {@inheritdoc} |
| 226 | 226 | */ |
| 227 | - public function withQuery($query) |
|
| 227 | + public function withQuery ($query) |
|
| 228 | 228 | { |
| 229 | - return $this->withString($query); |
|
| 229 | + return $this->withString ($query); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | 233 | * {@inheritdoc} |
| 234 | 234 | */ |
| 235 | - public function withFragment($fragment) |
|
| 235 | + public function withFragment ($fragment) |
|
| 236 | 236 | { |
| 237 | - return $this->withString($fragment, 'fragment'); |
|
| 237 | + return $this->withString ($fragment, 'fragment'); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | * @param string $name (default: 'query') |
| 246 | 246 | * @return Uri |
| 247 | 247 | */ |
| 248 | - protected function withString($string, $name = 'query') |
|
| 248 | + protected function withString ($string, $name = 'query') |
|
| 249 | 249 | { |
| 250 | - if (!is_string($string) && !method_exists($string, '__toString')) { |
|
| 251 | - throw new InvalidArgumentException('Uri fragment must be a string'); |
|
| 250 | + if (!is_string ($string) && !method_exists ($string, '__toString')) { |
|
| 251 | + throw new InvalidArgumentException ('Uri fragment must be a string'); |
|
| 252 | 252 | } |
| 253 | - $string = ltrim((string) $string, '#'); |
|
| 253 | + $string = ltrim ((string) $string, '#'); |
|
| 254 | 254 | $clone = clone $this; |
| 255 | - $clone->$name = $this->filterQuery($string); |
|
| 255 | + $clone->$name = $this->filterQuery ($string); |
|
| 256 | 256 | |
| 257 | 257 | return $clone; |
| 258 | 258 | } |
@@ -260,15 +260,15 @@ discard block |
||
| 260 | 260 | /** |
| 261 | 261 | * {@inheritdoc} |
| 262 | 262 | */ |
| 263 | - public function __toString() |
|
| 263 | + public function __toString () |
|
| 264 | 264 | { |
| 265 | - $scheme = $this->getScheme(); |
|
| 266 | - $authority = $this->getAuthority(); |
|
| 267 | - $path = $this->getPath(); |
|
| 268 | - $query = $this->getQuery(); |
|
| 269 | - $fragment = $this->getFragment(); |
|
| 265 | + $scheme = $this->getScheme (); |
|
| 266 | + $authority = $this->getAuthority (); |
|
| 267 | + $path = $this->getPath (); |
|
| 268 | + $query = $this->getQuery (); |
|
| 269 | + $fragment = $this->getFragment (); |
|
| 270 | 270 | |
| 271 | - $path = '/' . ltrim($path, '/'); |
|
| 271 | + $path = '/' . ltrim ($path, '/'); |
|
| 272 | 272 | |
| 273 | 273 | return ($scheme ? $scheme . ':' : '') |
| 274 | 274 | . ($authority ? '//' . $authority : '') |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @return string $scheme |
| 290 | 290 | * @throws InvalidArgumentException if not corret scheme is present |
| 291 | 291 | */ |
| 292 | - protected function filterScheme(string $scheme) |
|
| 292 | + protected function filterScheme (string $scheme) |
|
| 293 | 293 | { |
| 294 | 294 | static $valid = [ |
| 295 | 295 | '' => true, |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | 'http' => true, |
| 298 | 298 | ]; |
| 299 | 299 | |
| 300 | - $scheme = str_replace('://', '', strtolower($scheme)); |
|
| 300 | + $scheme = str_replace ('://', '', strtolower ($scheme)); |
|
| 301 | 301 | if (!isset($valid[$scheme])) { |
| 302 | - throw new InvalidArgumentException('Uri scheme must be one of: "", "https", "http"'); |
|
| 302 | + throw new InvalidArgumentException ('Uri scheme must be one of: "", "https", "http"'); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | return $scheme; |
@@ -314,14 +314,14 @@ discard block |
||
| 314 | 314 | * @return null|integer $port |
| 315 | 315 | * @throws InvalidArgumentException for incorrect port assigned |
| 316 | 316 | */ |
| 317 | - protected function filterPort($port) |
|
| 317 | + protected function filterPort ($port) |
|
| 318 | 318 | { |
| 319 | 319 | |
| 320 | 320 | if ((integer) $port >= 0 && (integer) $port <= 65535) { |
| 321 | 321 | return $port; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - throw new InvalidArgumentException('Uri port must be null or an integer between 1 and 65535 (inclusive)'); |
|
| 324 | + throw new InvalidArgumentException ('Uri port must be null or an integer between 1 and 65535 (inclusive)'); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -331,12 +331,12 @@ discard block |
||
| 331 | 331 | * @param string $path |
| 332 | 332 | * @return string of cleared path |
| 333 | 333 | */ |
| 334 | - protected function filterPath($path) |
|
| 334 | + protected function filterPath ($path) |
|
| 335 | 335 | { |
| 336 | - return preg_replace_callback( |
|
| 336 | + return preg_replace_callback ( |
|
| 337 | 337 | '/(?:[^a-zA-Z0-9_\-\.~:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/', |
| 338 | 338 | function ($match) { |
| 339 | - return rawurlencode($match[0]); |
|
| 339 | + return rawurlencode ($match[0]); |
|
| 340 | 340 | }, |
| 341 | 341 | $path |
| 342 | 342 | ); |
@@ -349,12 +349,12 @@ discard block |
||
| 349 | 349 | * @param string $query |
| 350 | 350 | * @return string of replaced query |
| 351 | 351 | */ |
| 352 | - protected function filterQuery($query) |
|
| 352 | + protected function filterQuery ($query) |
|
| 353 | 353 | { |
| 354 | - return preg_replace_callback( |
|
| 354 | + return preg_replace_callback ( |
|
| 355 | 355 | '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/', |
| 356 | 356 | function ($match) { |
| 357 | - return rawurlencode($match[0]); |
|
| 357 | + return rawurlencode ($match[0]); |
|
| 358 | 358 | }, |
| 359 | 359 | $query |
| 360 | 360 | ); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @access protected |
| 367 | 367 | * @return boolean |
| 368 | 368 | */ |
| 369 | - protected function hasStandardPort() |
|
| 369 | + protected function hasStandardPort () |
|
| 370 | 370 | { |
| 371 | 371 | return ($this->scheme === 'http' && $this->port === 80) || ($this->scheme === 'https' && $this->port === 443); |
| 372 | 372 | } |
@@ -377,10 +377,10 @@ discard block |
||
| 377 | 377 | * @access public |
| 378 | 378 | * @return string |
| 379 | 379 | */ |
| 380 | - public function getBaseUrl() |
|
| 380 | + public function getBaseUrl () |
|
| 381 | 381 | { |
| 382 | - $scheme = $this->getScheme(); |
|
| 383 | - $authority = $this->getAuthority(); |
|
| 382 | + $scheme = $this->getScheme (); |
|
| 383 | + $authority = $this->getAuthority (); |
|
| 384 | 384 | |
| 385 | 385 | return ($scheme ? $scheme . ':' : '') |
| 386 | 386 | . ($authority ? '//' . $authority : ''); |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | * @static |
| 15 | 15 | * @return Resilient\Http\Uri |
| 16 | 16 | */ |
| 17 | - public static function createFromServer($serv) |
|
| 17 | + public static function createFromServer ($serv) |
|
| 18 | 18 | { |
| 19 | 19 | $scheme = isset($serv['HTTPS']) ? 'https://' : 'http://'; |
| 20 | 20 | $host = !empty($serv['HTTP_HOST']) ? $serv['HTTP_HOST'] : $serv['SERVER_NAME']; |
| 21 | 21 | $port = empty($serv['SERVER_PORT']) ? $serv['SERVER_PORT'] : null; |
| 22 | 22 | |
| 23 | - $path = (string) parse_url('http://www.example.com/' . $serv['REQUEST_URI'], PHP_URL_PATH); |
|
| 23 | + $path = (string) parse_url ('http://www.example.com/' . $serv['REQUEST_URI'], PHP_URL_PATH); |
|
| 24 | 24 | |
| 25 | - $query = empty($serv['QUERY_STRING']) ? parse_url('http://example.com' . $serv['REQUEST_URI'], PHP_URL_QUERY) : $serv['QUERY_STRING']; |
|
| 25 | + $query = empty($serv['QUERY_STRING']) ? parse_url ('http://example.com' . $serv['REQUEST_URI'], PHP_URL_QUERY) : $serv['QUERY_STRING']; |
|
| 26 | 26 | |
| 27 | 27 | $fragment = ''; |
| 28 | 28 | |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | $password = !empty($serv['PHP_AUTH_PW']) ? $serv['PHP_AUTH_PW'] : ''; |
| 31 | 31 | |
| 32 | 32 | if (empty($user) && empty($password) && !empty($serv['HTTP_AUTHORIZATION'])) { |
| 33 | - list($user, $password) = explode(':', base64_decode(substr($serv['HTTP_AUTHORIZATION'], 6))); |
|
| 33 | + list($user, $password) = explode (':', base64_decode (substr ($serv['HTTP_AUTHORIZATION'], 6))); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $uri = new \Resilient\Http\Uri($scheme, $host, $port, $path, $query, $fragment, $user, $password); |
|
| 36 | + $uri = new \Resilient\Http\Uri ($scheme, $host, $port, $path, $query, $fragment, $user, $password); |
|
| 37 | 37 | |
| 38 | 38 | return $uri; |
| 39 | 39 | } |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | * @param string $uri |
| 48 | 48 | * @return Resilient\Http\Uri |
| 49 | 49 | */ |
| 50 | - public static function createFromString(string $uri) |
|
| 50 | + public static function createFromString (string $uri) |
|
| 51 | 51 | { |
| 52 | - $parts = parse_url($uri); |
|
| 52 | + $parts = parse_url ($uri); |
|
| 53 | 53 | $scheme = isset($parts['scheme']) ? $parts['scheme'] : ''; |
| 54 | 54 | $user = isset($parts['user']) ? $parts['user'] : ''; |
| 55 | 55 | $pass = isset($parts['pass']) ? $parts['pass'] : ''; |
@@ -59,6 +59,6 @@ discard block |
||
| 59 | 59 | $query = isset($parts['query']) ? $parts['query'] : ''; |
| 60 | 60 | $fragment = isset($parts['fragment']) ? $parts['fragment'] : ''; |
| 61 | 61 | |
| 62 | - return new \Resilient\Http\Uri($scheme, $host, $port, $path, $query, $fragment, $user, $pass); |
|
| 62 | + return new \Resilient\Http\Uri ($scheme, $host, $port, $path, $query, $fragment, $user, $pass); |
|
| 63 | 63 | } |
| 64 | 64 | } |