@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $content = $this->getResponse($docBlock['tags']); |
| 59 | 59 | |
| 60 | 60 | return [ |
| 61 | - 'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))), |
|
| 61 | + 'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))), |
|
| 62 | 62 | 'resource' => $routeGroup, |
| 63 | 63 | 'title' => $docBlock['short'], |
| 64 | 64 | 'description' => $docBlock['long'], |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | 'uri' => $this->getUri($route), |
| 67 | 67 | 'parameters' => $this->getParametersFromDocBlock($docBlock['tags']), |
| 68 | 68 | 'response' => $content, |
| 69 | - 'showresponse' => ! empty($content), |
|
| 69 | + 'showresponse' => !empty($content), |
|
| 70 | 70 | ]; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | protected function getDocblockResponse($tags) |
| 90 | 90 | { |
| 91 | - $responseTags = array_filter($tags, function ($tag) { |
|
| 91 | + $responseTags = array_filter($tags, function($tag) { |
|
| 92 | 92 | return $tag instanceof Tag && \strtolower($tag->getName()) == 'response'; |
| 93 | 93 | }); |
| 94 | 94 | if (empty($responseTags)) { |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | protected function getParametersFromDocBlock($tags) |
| 108 | 108 | { |
| 109 | 109 | $parameters = collect($tags) |
| 110 | - ->filter(function ($tag) { |
|
| 110 | + ->filter(function($tag) { |
|
| 111 | 111 | return $tag instanceof Tag && $tag->getName() === 'bodyParam'; |
| 112 | 112 | }) |
| 113 | - ->mapWithKeys(function ($tag) { |
|
| 113 | + ->mapWithKeys(function($tag) { |
|
| 114 | 114 | preg_match('/(.+?)\s+(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content); |
| 115 | 115 | if (empty($content)) { |
| 116 | 116 | // this means only name and type were supplied |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $methods = $this->getMethods($route); |
| 151 | 151 | |
| 152 | 152 | // Split headers into key - value pairs |
| 153 | - $headers = collect($headers)->map(function ($value) { |
|
| 153 | + $headers = collect($headers)->map(function($value) { |
|
| 154 | 154 | $split = explode(':', $value); // explode to get key + values |
| 155 | 155 | $key = array_shift($split); // extract the key and keep the values in the array |
| 156 | 156 | $value = implode(':', $split); // implode values into string again |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | { |
| 175 | 175 | $uri = $this->getUri($route); |
| 176 | 176 | foreach ($bindings as $model => $id) { |
| 177 | - $uri = str_replace('{'.$model.'}', $id, $uri); |
|
| 178 | - $uri = str_replace('{'.$model.'?}', $id, $uri); |
|
| 177 | + $uri = str_replace('{' . $model . '}', $id, $uri); |
|
| 178 | + $uri = str_replace('{' . $model . '?}', $id, $uri); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | return $uri; |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | foreach ($headers as $name => $value) { |
| 255 | 255 | $name = strtr(strtoupper($name), '-', '_'); |
| 256 | 256 | |
| 257 | - if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 258 | - $name = $prefix.$name; |
|
| 257 | + if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 258 | + $name = $prefix . $name; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | $server[$name] = $value; |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | protected function getTransformerResponse($tags) |
| 294 | 294 | { |
| 295 | 295 | try { |
| 296 | - $transFormerTags = array_filter($tags, function ($tag) { |
|
| 297 | - if (! ($tag instanceof Tag)) { |
|
| 296 | + $transFormerTags = array_filter($tags, function($tag) { |
|
| 297 | + if (!($tag instanceof Tag)) { |
|
| 298 | 298 | return false; |
| 299 | 299 | } |
| 300 | 300 | |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | return false; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $modelTag = array_first(array_filter($tags, function ($tag) { |
|
| 309 | - if (! ($tag instanceof Tag)) { |
|
| 308 | + $modelTag = array_first(array_filter($tags, function($tag) { |
|
| 309 | + if (!($tag instanceof Tag)) { |
|
| 310 | 310 | return false; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | })); |
| 315 | 315 | $tag = \array_first($transFormerTags); |
| 316 | 316 | $transformer = $tag->getContent(); |
| 317 | - if (! \class_exists($transformer)) { |
|
| 317 | + if (!\class_exists($transformer)) { |
|
| 318 | 318 | // if we can't find the transformer we can't generate a response |
| 319 | 319 | return; |
| 320 | 320 | } |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | if (\is_null($type)) { |
| 331 | 331 | if ($parameter->hasType() && |
| 332 | - ! $parameter->getType()->isBuiltin() && |
|
| 332 | + !$parameter->getType()->isBuiltin() && |
|
| 333 | 333 | \class_exists((string) $parameter->getType())) { |
| 334 | 334 | //we have a type |
| 335 | 335 | $type = (string) $parameter->getType(); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | // we have a response from the docblock ( @response ) |
| 383 | 383 | $response = $docblockResponse; |
| 384 | 384 | } |
| 385 | - if (! $response && ($transformerResponse = $this->getTransformerResponse($annotationTags))) { |
|
| 385 | + if (!$response && ($transformerResponse = $this->getTransformerResponse($annotationTags))) { |
|
| 386 | 386 | // we have a transformer response from the docblock ( @transformer || @transformercollection ) |
| 387 | 387 | $response = $transformerResponse; |
| 388 | 388 | } |
@@ -407,25 +407,25 @@ discard block |
||
| 407 | 407 | { |
| 408 | 408 | $faker = Factory::create(); |
| 409 | 409 | $fakes = [ |
| 410 | - 'integer' => function () { |
|
| 410 | + 'integer' => function() { |
|
| 411 | 411 | return rand(1, 20); |
| 412 | 412 | }, |
| 413 | - 'number' => function () use ($faker) { |
|
| 413 | + 'number' => function() use ($faker) { |
|
| 414 | 414 | return $faker->randomFloat(); |
| 415 | 415 | }, |
| 416 | - 'float' => function () use ($faker) { |
|
| 416 | + 'float' => function() use ($faker) { |
|
| 417 | 417 | return $faker->randomFloat(); |
| 418 | 418 | }, |
| 419 | - 'boolean' => function () use ($faker) { |
|
| 419 | + 'boolean' => function() use ($faker) { |
|
| 420 | 420 | return $faker->boolean(); |
| 421 | 421 | }, |
| 422 | - 'string' => function () use ($faker) { |
|
| 422 | + 'string' => function() use ($faker) { |
|
| 423 | 423 | return str_random(); |
| 424 | 424 | }, |
| 425 | - 'array' => function () { |
|
| 425 | + 'array' => function() { |
|
| 426 | 426 | return '[]'; |
| 427 | 427 | }, |
| 428 | - 'object' => function () { |
|
| 428 | + 'object' => function() { |
|
| 429 | 429 | return '{}'; |
| 430 | 430 | }, |
| 431 | 431 | ]; |