@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @param Route $route |
16 | 16 | * |
17 | - * @return mixed |
|
17 | + * @return string |
|
18 | 18 | */ |
19 | 19 | public function getUri(Route $route) |
20 | 20 | { |
@@ -33,7 +33,6 @@ discard block |
||
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @param \Illuminate\Routing\Route $route |
36 | - * @param array $apply Rules to apply when generating documentation for this route |
|
37 | 36 | * |
38 | 37 | * @return array |
39 | 38 | */ |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | ]); |
70 | 70 | |
71 | 71 | $parsedRoute = [ |
72 | - 'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))), |
|
72 | + 'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))), |
|
73 | 73 | 'groupName' => $routeGroupName, |
74 | 74 | 'groupDescription' => $routeGroupDescription, |
75 | 75 | 'title' => $docBlock['short'], |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'cleanQueryParameters' => $this->cleanParams($queryParameters), |
84 | 84 | 'authenticated' => $this->getAuthStatusFromDocBlock($docBlock['tags']), |
85 | 85 | 'response' => $content, |
86 | - 'showresponse' => ! empty($content), |
|
86 | + 'showresponse' => !empty($content), |
|
87 | 87 | ]; |
88 | 88 | $parsedRoute['headers'] = $rulesToApply['headers'] ?? []; |
89 | 89 | |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | protected function getBodyParametersFromDocBlock(array $tags) |
130 | 130 | { |
131 | 131 | $parameters = collect($tags) |
132 | - ->filter(function ($tag) { |
|
132 | + ->filter(function($tag) { |
|
133 | 133 | return $tag instanceof Tag && $tag->getName() === 'bodyParam'; |
134 | 134 | }) |
135 | - ->mapWithKeys(function ($tag) { |
|
135 | + ->mapWithKeys(function($tag) { |
|
136 | 136 | preg_match('/(.+?)\s+(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content); |
137 | 137 | if (empty($content)) { |
138 | 138 | // this means only name and type were supplied |
@@ -204,10 +204,10 @@ discard block |
||
204 | 204 | protected function getQueryParametersFromDocBlock(array $tags) |
205 | 205 | { |
206 | 206 | $parameters = collect($tags) |
207 | - ->filter(function ($tag) { |
|
207 | + ->filter(function($tag) { |
|
208 | 208 | return $tag instanceof Tag && $tag->getName() === 'queryParam'; |
209 | 209 | }) |
210 | - ->mapWithKeys(function ($tag) { |
|
210 | + ->mapWithKeys(function($tag) { |
|
211 | 211 | preg_match('/(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content); |
212 | 212 | if (empty($content)) { |
213 | 213 | // this means only name was supplied |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | protected function getAuthStatusFromDocBlock(array $tags) |
246 | 246 | { |
247 | 247 | $authTag = collect($tags) |
248 | - ->first(function ($tag) { |
|
248 | + ->first(function($tag) { |
|
249 | 249 | return $tag instanceof Tag && strtolower($tag->getName()) === 'authenticated'; |
250 | 250 | }); |
251 | 251 | |
@@ -328,25 +328,25 @@ discard block |
||
328 | 328 | $faker->seed($this->config->get('faker_seed')); |
329 | 329 | } |
330 | 330 | $fakeFactories = [ |
331 | - 'integer' => function () use ($faker) { |
|
331 | + 'integer' => function() use ($faker) { |
|
332 | 332 | return $faker->numberBetween(1, 20); |
333 | 333 | }, |
334 | - 'number' => function () use ($faker) { |
|
334 | + 'number' => function() use ($faker) { |
|
335 | 335 | return $faker->randomFloat(); |
336 | 336 | }, |
337 | - 'float' => function () use ($faker) { |
|
337 | + 'float' => function() use ($faker) { |
|
338 | 338 | return $faker->randomFloat(); |
339 | 339 | }, |
340 | - 'boolean' => function () use ($faker) { |
|
340 | + 'boolean' => function() use ($faker) { |
|
341 | 341 | return $faker->boolean(); |
342 | 342 | }, |
343 | - 'string' => function () use ($faker) { |
|
343 | + 'string' => function() use ($faker) { |
|
344 | 344 | return $faker->word; |
345 | 345 | }, |
346 | - 'array' => function () { |
|
346 | + 'array' => function() { |
|
347 | 347 | return []; |
348 | 348 | }, |
349 | - 'object' => function () { |
|
349 | + 'object' => function() { |
|
350 | 350 | return new \stdClass; |
351 | 351 | }, |
352 | 352 | ]; |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | |
51 | 51 | private function getAllRoutes(bool $usingDingoRouter, array $versions = []) |
52 | 52 | { |
53 | - if (! $usingDingoRouter) { |
|
53 | + if (!$usingDingoRouter) { |
|
54 | 54 | return RouteFacade::getRoutes(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes(); |
58 | 58 | |
59 | 59 | return collect($allRouteCollections) |
60 | - ->flatMap(function (RouteCollection $collection) { |
|
60 | + ->flatMap(function(RouteCollection $collection) { |
|
61 | 61 | return $collection->getRoutes(); |
62 | 62 | })->toArray(); |
63 | 63 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter) |
66 | 66 | { |
67 | 67 | $matchesVersion = $usingDingoRouter |
68 | - ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
68 | + ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
69 | 69 | : true; |
70 | 70 | |
71 | 71 | return str_is($mustIncludes, $route->getName()) |
@@ -48,8 +48,8 @@ |
||
48 | 48 | /** @var Response[]|null $response */ |
49 | 49 | $responses = $strategy($this->route, $tags, $routeProps); |
50 | 50 | |
51 | - if (! is_null($responses)) { |
|
52 | - return array_map(function (Response $response) { |
|
51 | + if (!is_null($responses)) { |
|
52 | + return array_map(function(Response $response) { |
|
53 | 53 | return ['status' => $response->getStatusCode(), 'content' => $this->getResponseContent($response)]; |
54 | 54 | }, $responses); |
55 | 55 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | protected function getDocBlockResponses(array $tags) |
34 | 34 | { |
35 | 35 | $responseTags = array_values( |
36 | - array_filter($tags, function ($tag) { |
|
36 | + array_filter($tags, function($tag) { |
|
37 | 37 | return $tag instanceof Tag && strtolower($tag->getName()) === 'response'; |
38 | 38 | }) |
39 | 39 | ); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | - return array_map(function (Tag $responseTag) { |
|
45 | + return array_map(function(Tag $responseTag) { |
|
46 | 46 | preg_match('/^(\d{3})?\s?([\s\S]*)$/', $responseTag->getContent(), $result); |
47 | 47 | |
48 | 48 | $status = $result[1] ?: 200; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | // avoid "holes" in the keys of the filtered array, by using array_values on the filtered array |
36 | 36 | $responseFileTags = array_values( |
37 | - array_filter($tags, function ($tag) { |
|
37 | + array_filter($tags, function($tag) { |
|
38 | 38 | return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile'; |
39 | 39 | }) |
40 | 40 | ); |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | - return array_map(function (Tag $responseFileTag) { |
|
46 | + return array_map(function(Tag $responseFileTag) { |
|
47 | 47 | preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result); |
48 | 48 | $status = $result[1] ?: 200; |
49 | 49 | $content = $result[2] ? file_get_contents(storage_path(trim($result[2])), true) : '{}'; |
50 | - $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; |
|
50 | + $json = !empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; |
|
51 | 51 | $merged = array_merge(json_decode($content, true), json_decode($json, true)); |
52 | 52 | |
53 | 53 | return new JsonResponse($merged, (int) $status); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $fractal = new Manager(); |
49 | 49 | |
50 | - if (! is_null(config('apidoc.fractal.serializer'))) { |
|
50 | + if (!is_null(config('apidoc.fractal.serializer'))) { |
|
51 | 51 | $fractal->setSerializer(app(config('apidoc.fractal.serializer'))); |
52 | 52 | } |
53 | 53 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod) |
81 | 81 | { |
82 | - $modelTag = array_first(array_filter($tags, function ($tag) { |
|
82 | + $modelTag = array_first(array_filter($tags, function($tag) { |
|
83 | 83 | return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel'; |
84 | 84 | })); |
85 | 85 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $type = $modelTag->getContent(); |
89 | 89 | } else { |
90 | 90 | $parameter = array_first($transformerMethod->getParameters()); |
91 | - if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) { |
|
91 | + if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) { |
|
92 | 92 | // ladies and gentlemen, we have a type! |
93 | 93 | $type = (string) $parameter->getType(); |
94 | 94 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | private function getTransformerTag(array $tags) |
134 | 134 | { |
135 | 135 | $transFormerTags = array_values( |
136 | - array_filter($tags, function ($tag) { |
|
136 | + array_filter($tags, function($tag) { |
|
137 | 137 | return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']); |
138 | 138 | }) |
139 | 139 | ); |
@@ -15,17 +15,17 @@ |
||
15 | 15 | */ |
16 | 16 | public function boot() |
17 | 17 | { |
18 | - $this->loadViewsFrom(__DIR__.'/../resources/views/', 'apidoc'); |
|
18 | + $this->loadViewsFrom(__DIR__ . '/../resources/views/', 'apidoc'); |
|
19 | 19 | |
20 | 20 | $this->publishes([ |
21 | - __DIR__.'/../resources/views' => app()->basePath().'/resources/views/vendor/apidoc', |
|
21 | + __DIR__ . '/../resources/views' => app()->basePath() . '/resources/views/vendor/apidoc', |
|
22 | 22 | ], 'apidoc-views'); |
23 | 23 | |
24 | 24 | $this->publishes([ |
25 | - __DIR__.'/../config/apidoc.php' => app()->basePath().'/config/apidoc.php', |
|
25 | + __DIR__ . '/../config/apidoc.php' => app()->basePath() . '/config/apidoc.php', |
|
26 | 26 | ], 'apidoc-config'); |
27 | 27 | |
28 | - $this->mergeConfigFrom(__DIR__.'/../config/apidoc.php', 'apidoc'); |
|
28 | + $this->mergeConfigFrom(__DIR__ . '/../config/apidoc.php', 'apidoc'); |
|
29 | 29 | |
30 | 30 | if ($this->app->runningInConsole()) { |
31 | 31 | $this->commands([ |
@@ -84,7 +84,6 @@ |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | - * @param array $config |
|
88 | 87 | * |
89 | 88 | * @return void |
90 | 89 | * |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function __invoke(Route $route, array $tags, array $routeProps) |
28 | 28 | { |
29 | 29 | $rulesToApply = $routeProps['rules']['response_calls'] ?? []; |
30 | - if (! $this->shouldMakeApiCall($route, $rulesToApply)) { |
|
30 | + if (!$this->shouldMakeApiCall($route, $rulesToApply)) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | try { |
38 | 38 | $response = [$this->makeApiCall($request)]; |
39 | 39 | } catch (\Exception $e) { |
40 | - echo 'Exception thrown during response call for ['.implode(',', $route->methods)."] {$route->uri}.\n"; |
|
40 | + echo 'Exception thrown during response call for [' . implode(',', $route->methods) . "] {$route->uri}.\n"; |
|
41 | 41 | if (Flags::$shouldBeVerbose) { |
42 | 42 | Utils::dumpException($e); |
43 | 43 | } else { |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | // set URL and query parameters |
175 | 175 | $uri = $request->getRequestUri(); |
176 | 176 | $query = $request->getQueryString(); |
177 | - if (! empty($query)) { |
|
177 | + if (!empty($query)) { |
|
178 | 178 | $uri .= "?$query"; |
179 | 179 | } |
180 | 180 | $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]); |
181 | 181 | |
182 | 182 | // the response from the Dingo dispatcher is the 'raw' response from the controller, |
183 | 183 | // so we have to ensure it's JSON first |
184 | - if (! $response instanceof Response) { |
|
184 | + if (!$response instanceof Response) { |
|
185 | 185 | $response = response()->json($response); |
186 | 186 | } |
187 | 187 | |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | $prefix = 'HTTP_'; |
331 | 331 | foreach ($headers as $name => $value) { |
332 | 332 | $name = strtr(strtoupper($name), '-', '_'); |
333 | - if (! starts_with($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
334 | - $name = $prefix.$name; |
|
333 | + if (!starts_with($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
334 | + $name = $prefix . $name; |
|
335 | 335 | } |
336 | 336 | $server[$name] = $value; |
337 | 337 | } |
@@ -42,15 +42,15 @@ |
||
42 | 42 | |
43 | 43 | $documentarian = new Documentarian(); |
44 | 44 | |
45 | - if (! is_dir($outputPath)) { |
|
46 | - $this->error('There is no existing documentation available at '.$outputPath.'.'); |
|
45 | + if (!is_dir($outputPath)) { |
|
46 | + $this->error('There is no existing documentation available at ' . $outputPath . '.'); |
|
47 | 47 | |
48 | 48 | return false; |
49 | 49 | } |
50 | - $this->info('Rebuilding API HTML code from '.$outputPath.'/source/index.md'); |
|
50 | + $this->info('Rebuilding API HTML code from ' . $outputPath . '/source/index.md'); |
|
51 | 51 | |
52 | 52 | $documentarian->generate($outputPath); |
53 | 53 | |
54 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
54 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
55 | 55 | } |
56 | 56 | } |