@@ -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,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function render(ResourceObject $ro) |
63 | 63 | { |
64 | - $method = 'on' . ucfirst($ro->uri->method); |
|
65 | - if (! method_exists($ro, $method)) { |
|
64 | + $method = 'on'.ucfirst($ro->uri->method); |
|
65 | + if (!method_exists($ro, $method)) { |
|
66 | 66 | $ro->view = ''; // no view for OPTIONS request |
67 | 67 | |
68 | 68 | return ''; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | /* @var $annotations Link[] */ |
83 | 83 | /* @var $ro ResourceObject */ |
84 | 84 | $hal = $this->getHal($ro->uri, $body, $annotations); |
85 | - $ro->view = $hal->asJson(true) . PHP_EOL; |
|
85 | + $ro->view = $hal->asJson(true).PHP_EOL; |
|
86 | 86 | $this->updateHeaders($ro); |
87 | 87 | |
88 | 88 | return $ro->view; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | return $ro->view; |
113 | 113 | } |
114 | 114 | |
115 | - private function valuateElements(ResourceObject &$ro) |
|
115 | + private function valuateElements(ResourceObject & $ro) |
|
116 | 116 | { |
117 | 117 | foreach ($ro->body as $key => &$embeded) { |
118 | 118 | if ($embeded instanceof AbstractRequest) { |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function isDifferentSchema(ResourceObject $parentRo, ResourceObject $childRo) : bool |
136 | 136 | { |
137 | - return $parentRo->uri->scheme . $parentRo->uri->host !== $childRo->uri->scheme . $childRo->uri->host; |
|
137 | + return $parentRo->uri->scheme.$parentRo->uri->host !== $childRo->uri->scheme.$childRo->uri->host; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | private function getHal(AbstractUri $uri, array $body, array $annotations) : Hal |
141 | 141 | { |
142 | - $query = $uri->query ? '?' . http_build_query($uri->query) : ''; |
|
143 | - $path = $uri->path . $query; |
|
142 | + $query = $uri->query ? '?'.http_build_query($uri->query) : ''; |
|
143 | + $path = $uri->path.$query; |
|
144 | 144 | $selfLink = $this->getReverseMatchedLink($path); |
145 | 145 | |
146 | 146 | $hal = new Hal($selfLink, $body); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($this->curies instanceof Curies) { |
194 | 194 | $hal->addCurie($this->curies->name, $this->curies->href); |
195 | 195 | } |
196 | - if (! empty($methodAnnotations)) { |
|
196 | + if (!empty($methodAnnotations)) { |
|
197 | 197 | $hal = $this->linkAnnotation($body, $methodAnnotations, $hal); |
198 | 198 | } |
199 | 199 | if (isset($body['_links'])) { |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | private function linkAnnotation(array $body, array $methodAnnotations, Hal $hal) : Hal |
231 | 231 | { |
232 | 232 | foreach ($methodAnnotations as $annotation) { |
233 | - if (! $annotation instanceof Link) { |
|
233 | + if (!$annotation instanceof Link) { |
|
234 | 234 | continue; |
235 | 235 | } |
236 | 236 | $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; |