@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $this->method = $options['method']; |
51 | 51 | $this->path = $options['path']; |
52 | - $this->version = null !== $version ? '{version:' . $version . '}' : '{version:any}'; |
|
52 | + $this->version = null !== $version ? '{version:'.$version.'}' : '{version:any}'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -59,20 +59,20 @@ discard block |
||
59 | 59 | */ |
60 | 60 | protected function validate(array $options): void |
61 | 61 | { |
62 | - if (! isset($options['method'])) { |
|
62 | + if ( ! isset($options['method'])) { |
|
63 | 63 | throw new InvalidArgumentException('method property is missing'); |
64 | - } elseif (! in_array($options['method'], ['GET', 'POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE', 'HEAD'])) { |
|
64 | + } elseif ( ! in_array($options['method'], ['GET', 'POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE', 'HEAD'])) { |
|
65 | 65 | throw new InvalidArgumentException('method property is not valid'); |
66 | - } elseif (! isset($options['path'])) { |
|
66 | + } elseif ( ! isset($options['path'])) { |
|
67 | 67 | throw new InvalidArgumentException('path property is missing'); |
68 | 68 | } elseif ( |
69 | 69 | isset($options['since']) |
70 | - && ! preg_match('#^' . Application::API_VERSION_REG_EXP . '$#', $options['since']) |
|
70 | + && ! preg_match('#^'.Application::API_VERSION_REG_EXP.'$#', $options['since']) |
|
71 | 71 | ) { |
72 | 72 | throw new InvalidArgumentException('since property is not valid'); |
73 | 73 | } elseif ( |
74 | 74 | isset($options['until']) |
75 | - && ! preg_match('#^' . Application::API_VERSION_REG_EXP . '$#', $options['until']) |
|
75 | + && ! preg_match('#^'.Application::API_VERSION_REG_EXP.'$#', $options['until']) |
|
76 | 76 | ) { |
77 | 77 | throw new InvalidArgumentException('until property is not valid'); |
78 | 78 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $sinceVersion = str_pad($sinceVersion, 3, '.0'); |
90 | 90 | $untilVersion = str_pad($untilVersion, 3, '.0'); |
91 | 91 | |
92 | - if (! ($sinceVersion < $untilVersion)) { |
|
92 | + if ( ! ($sinceVersion < $untilVersion)) { |
|
93 | 93 | throw new LogicException('since must be lesser than until'); |
94 | 94 | } |
95 | 95 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | public function __construct(\Exception $exception) |
33 | 33 | { |
34 | - $this->code = (int) $exception->getCode(); |
|
34 | + $this->code = (int)$exception->getCode(); |
|
35 | 35 | $this->message = $exception->getMessage(); |
36 | 36 | |
37 | 37 | if ($exception instanceof Exception) { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function register(ContainerInterface $container, Configurable $config): void |
21 | 21 | { |
22 | - if (! $config instanceof Config) { |
|
22 | + if ( ! $config instanceof Config) { |
|
23 | 23 | throw new InvalidArgumentException('Wrong Config object'); |
24 | 24 | } |
25 | 25 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $hateoas->setDebug($config->debug); |
29 | 29 | $hateoas->setUrlGenerator(null, new CallableUrlGenerator($config->urlGenerator)); |
30 | 30 | |
31 | - if (! $config->debug) { |
|
31 | + if ( ! $config->debug) { |
|
32 | 32 | $hateoas->setCacheDir($config->cacheDir); |
33 | 33 | $hateoas->addMetadataDir($config->metadataDir); |
34 | 34 | } |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | continue; |
23 | 23 | } |
24 | 24 | |
25 | - $queryParams .= $paramName . '=' . $paramValue . '&'; |
|
25 | + $queryParams .= $paramName.'='.$paramValue.'&'; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | if ($queryParams !== '') { |
29 | - $queryParams = '?' . substr($queryParams, 0, -1); |
|
29 | + $queryParams = '?'.substr($queryParams, 0, -1); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $resourceParams = implode('/', $resourceParams); |
33 | 33 | |
34 | - if (! empty($resourceParams)) { |
|
35 | - $resourceParams = '/' . $resourceParams; |
|
34 | + if ( ! empty($resourceParams)) { |
|
35 | + $resourceParams = '/'.$resourceParams; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | if ($absolute) { |
39 | - return Request::createFromGlobals()->getSchemeAndHttpHost() . |
|
40 | - $route . |
|
41 | - $resourceParams . |
|
39 | + return Request::createFromGlobals()->getSchemeAndHttpHost(). |
|
40 | + $route. |
|
41 | + $resourceParams. |
|
42 | 42 | $queryParams; |
43 | 43 | } |
44 | 44 | |
45 | - return $route . $resourceParams . $queryParams; |
|
45 | + return $route.$resourceParams.$queryParams; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | $this->urlGenerator = $urlGenerator; |
63 | 63 | |
64 | 64 | if (null === $cacheDir) { |
65 | - $this->cacheDir = sys_get_temp_dir() . '/hateoas'; |
|
65 | + $this->cacheDir = sys_get_temp_dir().'/hateoas'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | if (null === $metadataDir) { |
69 | - $this->metadataDir = sys_get_temp_dir() . '/hateoas'; |
|
69 | + $this->metadataDir = sys_get_temp_dir().'/hateoas'; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if (null === $urlGenerator) { |
73 | - $this->urlGenerator = function ($route, array $parameters, $absolute) { |
|
73 | + $this->urlGenerator = function($route, array $parameters, $absolute) { |
|
74 | 74 | return $this->generateUrl($route, $parameters, $absolute); |
75 | 75 | }; |
76 | 76 | } |
@@ -59,17 +59,17 @@ |
||
59 | 59 | $router->addRoute( |
60 | 60 | $docblock->method, |
61 | 61 | $docblock->path, |
62 | - '\\' . $class->getName() . '::' . $method->getName() |
|
62 | + '\\'.$class->getName().'::'.$method->getName() |
|
63 | 63 | ); |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | protected function addVersionToRoute(Route $docblock): void |
68 | 68 | { |
69 | - if (! is_null($docblock->version) && $docblock->path[0] === '/') { |
|
70 | - $docblock->path = '/' . $docblock->version . $docblock->path; |
|
71 | - } elseif (! is_null($docblock->version) && $docblock->path[0] !== '/') { |
|
72 | - $docblock->path = '/' . $docblock->version . '/' . $docblock->path; |
|
69 | + if ( ! is_null($docblock->version) && $docblock->path[0] === '/') { |
|
70 | + $docblock->path = '/'.$docblock->version.$docblock->path; |
|
71 | + } elseif ( ! is_null($docblock->version) && $docblock->path[0] !== '/') { |
|
72 | + $docblock->path = '/'.$docblock->version.'/'.$docblock->path; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | if ( |
19 | 19 | preg_match( |
20 | - '#application/vnd\.' . $vendor . '-v' . $apiVersionRegExp . '\+(xml|json)#', |
|
20 | + '#application/vnd\.'.$vendor.'-v'.$apiVersionRegExp.'\+(xml|json)#', |
|
21 | 21 | $mime, |
22 | 22 | $matches |
23 | 23 | ) |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | [$mime, $apiVersion, $format] = $matches; |
26 | 26 | } elseif ( |
27 | 27 | preg_match( |
28 | - '#application/vnd\.' . $vendor . '\+(xml|json).*?version=' . $apiVersionRegExp . '#', |
|
28 | + '#application/vnd\.'.$vendor.'\+(xml|json).*?version='.$apiVersionRegExp.'#', |
|
29 | 29 | $mime, |
30 | 30 | $matches |
31 | 31 | ) |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | [$mime, $format, $apiVersion] = $matches; |
34 | 34 | } elseif ('application/json' === $mime) { |
35 | 35 | $format = 'json'; |
36 | - $mime = 'application/vnd.' . $vendor . '-v' . $apiVersion . '+json'; |
|
36 | + $mime = 'application/vnd.'.$vendor.'-v'.$apiVersion.'+json'; |
|
37 | 37 | } elseif ('application/xml' === $mime) { |
38 | 38 | $format = 'xml'; |
39 | - $mime = 'application/vnd.' . $vendor . '-v' . $apiVersion . '+xml'; |
|
39 | + $mime = 'application/vnd.'.$vendor.'-v'.$apiVersion.'+xml'; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return new MimeProcessResult($mime, $vendor, $apiVersion, $format); |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | public function __construct(string $vendor, string $apiVersion, bool $debug = false) |
37 | 37 | { |
38 | - if (! preg_match('#^' . Application::API_VERSION_REG_EXP . '$#', $apiVersion)) { |
|
38 | + if ( ! preg_match('#^'.Application::API_VERSION_REG_EXP.'$#', $apiVersion)) { |
|
39 | 39 | throw new InvalidArgumentException('Api version is not valid'); |
40 | 40 | } |
41 | 41 |