@@ -59,6 +59,9 @@ |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | + /** |
|
63 | + * @param string $method |
|
64 | + */ |
|
62 | 65 | private function isMagicMethod($method) : bool |
63 | 66 | { |
64 | 67 | return in_array($method, ['__sleep', '__wakeup', 'offsetGet', 'offsetSet', 'offsetExists', 'offsetUnset', 'count', 'ksort', 'asort', 'jsonSerialize'], true); |
@@ -67,7 +67,7 @@ |
||
67 | 67 | private function saveNamedParam(NamedParameterInterface $namedParameter, $instance, string $method) |
68 | 68 | { |
69 | 69 | // named parameter |
70 | - if (! in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
70 | + if (!in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
71 | 71 | return; |
72 | 72 | } |
73 | 73 | try { |
@@ -136,7 +136,7 @@ |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | - * @return mixed |
|
139 | + * @return string |
|
140 | 140 | */ |
141 | 141 | private function getReverseMatchedLink(string $uri) |
142 | 142 | { |
@@ -15,7 +15,6 @@ |
||
15 | 15 | use BEAR\Resource\RenderInterface; |
16 | 16 | use BEAR\Resource\ResourceInterface; |
17 | 17 | use BEAR\Resource\ResourceObject; |
18 | -use BEAR\Resource\Uri; |
|
19 | 18 | use BEAR\Sunday\Extension\Router\RouterInterface; |
20 | 19 | use Doctrine\Common\Annotations\Reader; |
21 | 20 | use Nocarrier\Hal; |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function render(ResourceObject $ro) |
63 | 63 | { |
64 | - $method = 'on' . ucfirst($ro->uri->method); |
|
64 | + $method = 'on'.ucfirst($ro->uri->method); |
|
65 | 65 | $hasMethod = method_exists($ro, $method); |
66 | - if (! $hasMethod) { |
|
66 | + if (!$hasMethod) { |
|
67 | 67 | $ro->view = ''; // OPTIONS request no view |
68 | 68 | |
69 | 69 | return ''; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /* @var $annotations Link[] */ |
82 | 82 | /* @var $ro ResourceObject */ |
83 | 83 | $hal = $this->getHal($ro->uri, $body, $annotations); |
84 | - $ro->view = $hal->asJson(true) . PHP_EOL; |
|
84 | + $ro->view = $hal->asJson(true).PHP_EOL; |
|
85 | 85 | $this->updateHeaders($ro); |
86 | 86 | |
87 | 87 | return $ro->view; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
101 | - private function valuateElements(ResourceObject &$ro) |
|
101 | + private function valuateElements(ResourceObject & $ro) |
|
102 | 102 | { |
103 | 103 | foreach ($ro->body as $key => &$embeded) { |
104 | 104 | if ($embeded instanceof AbstractRequest) { |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | */ |
121 | 121 | private function isDifferentSchema(ResourceObject $parentRo, ResourceObject $childRo) : bool |
122 | 122 | { |
123 | - return $parentRo->uri->scheme . $parentRo->uri->host !== $childRo->uri->scheme . $childRo->uri->host; |
|
123 | + return $parentRo->uri->scheme.$parentRo->uri->host !== $childRo->uri->scheme.$childRo->uri->host; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | private function getHal(AbstractUri $uri, array $body, array $annotations) : Hal |
127 | 127 | { |
128 | - $query = $uri->query ? '?' . http_build_query($uri->query) : ''; |
|
129 | - $path = $uri->path . $query; |
|
128 | + $query = $uri->query ? '?'.http_build_query($uri->query) : ''; |
|
129 | + $path = $uri->path.$query; |
|
130 | 130 | $selfLink = $this->getReverseMatchedLink($path); |
131 | 131 | |
132 | 132 | $hal = new Hal($selfLink, $body); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $hal->addCurie($this->curies->name, $this->curies->href); |
181 | 181 | } |
182 | 182 | foreach ($methodAnnotations as $annotation) { |
183 | - if (! $annotation instanceof Link) { |
|
183 | + if (!$annotation instanceof Link) { |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | $uri = uri_template($annotation->href, $body); |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function toString() |
23 | 23 | { |
24 | - $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL; |
|
24 | + $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | private function getHeader() : array |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function toString() |
23 | 23 | { |
24 | - $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL; |
|
24 | + $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | private function getHeader($code) : array |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | private function getParams($method, array $server, array $post) : array |
89 | 89 | { |
90 | 90 | // post data exists |
91 | - if ($method === 'post' && ! empty($post)) { |
|
91 | + if ($method === 'post' && !empty($post)) { |
|
92 | 92 | return $post; |
93 | 93 | } |
94 | 94 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | private function phpInput(array $server) : array |
106 | 106 | { |
107 | 107 | $contentType = $this->getContentType($server); |
108 | - if (! $contentType) { |
|
108 | + if (!$contentType) { |
|
109 | 109 | return []; |
110 | 110 | } |
111 | 111 | $isFormUrlEncoded = strpos($contentType, self::FORM_URL_ENCODE) !== false; |