@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | |
45 | 45 | $documentarian = new Documentarian(); |
46 | 46 | |
47 | - if (! is_dir($outputPath)) { |
|
48 | - $this->error('There is no generated documentation available at '.$outputPath.'.'); |
|
47 | + if (!is_dir($outputPath)) { |
|
48 | + $this->error('There is no generated documentation available at ' . $outputPath . '.'); |
|
49 | 49 | |
50 | 50 | return false; |
51 | 51 | } |
@@ -53,6 +53,6 @@ discard block |
||
53 | 53 | |
54 | 54 | $documentarian->generate($outputPath); |
55 | 55 | |
56 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/public/index.html'); |
|
56 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/public/index.html'); |
|
57 | 57 | } |
58 | 58 | } |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | public function with($parameters) |
35 | 35 | { |
36 | 36 | is_array($parameters) ? |
37 | - $this->parameters += $parameters : |
|
38 | - $this->parameters[] = $parameters; |
|
37 | + $this->parameters += $parameters : $this->parameters[] = $parameters; |
|
39 | 38 | |
40 | 39 | return $this; |
41 | 40 | } |
@@ -54,8 +53,7 @@ discard block |
||
54 | 53 | protected function makeDescription() |
55 | 54 | { |
56 | 55 | $description = trans()->hasForLocale($this->rule) ? |
57 | - trans()->get($this->rule) : |
|
58 | - trans()->get($this->rule, [], self::DEFAULT_LOCALE); |
|
56 | + trans()->get($this->rule) : trans()->get($this->rule, [], self::DEFAULT_LOCALE); |
|
59 | 57 | |
60 | 58 | return $this->replaceAttributes($description); |
61 | 59 | } |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function boot() |
17 | 17 | { |
18 | - $this->loadViewsFrom(__DIR__.'/../../resources/views/', 'apidoc'); |
|
19 | - $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'apidoc'); |
|
18 | + $this->loadViewsFrom(__DIR__ . '/../../resources/views/', 'apidoc'); |
|
19 | + $this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'apidoc'); |
|
20 | 20 | |
21 | 21 | $this->publishes([ |
22 | - __DIR__.'/../../resources/lang' => $this->resource_path('lang/vendor/apidoc'), |
|
23 | - __DIR__.'/../../resources/views' => $this->resource_path('views/vendor/apidoc'), |
|
22 | + __DIR__ . '/../../resources/lang' => $this->resource_path('lang/vendor/apidoc'), |
|
23 | + __DIR__ . '/../../resources/views' => $this->resource_path('views/vendor/apidoc'), |
|
24 | 24 | ]); |
25 | 25 | } |
26 | 26 | |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function register() |
33 | 33 | { |
34 | - $this->app->singleton('apidoc.generate', function () { |
|
34 | + $this->app->singleton('apidoc.generate', function() { |
|
35 | 35 | return new GenerateDocumentation(); |
36 | 36 | }); |
37 | - $this->app->singleton('apidoc.update', function () { |
|
37 | + $this->app->singleton('apidoc.update', function() { |
|
38 | 38 | return new UpdateDocumentation(); |
39 | 39 | }); |
40 | 40 | |
@@ -53,6 +53,6 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function resource_path($path = '') |
55 | 55 | { |
56 | - return app()->basePath().'/resources'.($path ? '/'.$path : $path); |
|
56 | + return app()->basePath() . '/resources' . ($path ? '/' . $path : $path); |
|
57 | 57 | } |
58 | 58 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | 'description' => '', |
33 | 33 | 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json', |
34 | 34 | ], |
35 | - 'item' => $this->routeGroups->map(function ($routes, $groupName) { |
|
35 | + 'item' => $this->routeGroups->map(function($routes, $groupName) { |
|
36 | 36 | return [ |
37 | 37 | 'name' => $groupName, |
38 | 38 | 'description' => '', |
39 | - 'item' => $routes->map(function ($route) { |
|
39 | + 'item' => $routes->map(function($route) { |
|
40 | 40 | return [ |
41 | 41 | 'name' => $route['title'] != '' ? $route['title'] : url($route['uri']), |
42 | 42 | 'request' => [ |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | 'method' => $route['methods'][0], |
45 | 45 | 'body' => [ |
46 | 46 | 'mode' => 'formdata', |
47 | - 'formdata' => collect($route['parameters'])->map(function ($parameter, $key) { |
|
47 | + 'formdata' => collect($route['parameters'])->map(function($parameter, $key) { |
|
48 | 48 | return [ |
49 | 49 | 'key' => $key, |
50 | 50 | 'value' => isset($parameter['value']) ? $parameter['value'] : '', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $this->setUserToBeImpersonated($this->option('actAsUserId')); |
73 | 73 | |
74 | - if ($routePrefix === null && ! count($allowedRoutes) && $middleware === null) { |
|
74 | + if ($routePrefix === null && !count($allowedRoutes) && $middleware === null) { |
|
75 | 75 | $this->error('You must provide either a route prefix or a route or a middleware to generate the documentation.'); |
76 | 76 | |
77 | 77 | return false; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } else { |
85 | 85 | $parsedRoutes = $this->processDingoRoutes($generator, $allowedRoutes, $routePrefix, $middleware); |
86 | 86 | } |
87 | - $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function ($a, $b) { |
|
87 | + $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function($a, $b) { |
|
88 | 88 | return strcmp($a->first()['resource'], $b->first()['resource']); |
89 | 89 | }); |
90 | 90 | |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | private function writeMarkdown($parsedRoutes) |
100 | 100 | { |
101 | 101 | $outputPath = $this->option('output'); |
102 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
103 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
102 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
103 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
104 | 104 | |
105 | 105 | $infoText = view('apidoc::partials.info') |
106 | 106 | ->with('outputPath', ltrim($outputPath, 'public/')) |
107 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')); |
|
107 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')); |
|
108 | 108 | |
109 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
110 | - return $routeGroup->map(function ($route) { |
|
109 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
110 | + return $routeGroup->map(function($route) { |
|
111 | 111 | $route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route)->render(); |
112 | 112 | |
113 | 113 | return $route; |
@@ -131,16 +131,16 @@ discard block |
||
131 | 131 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
132 | 132 | } |
133 | 133 | |
134 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
135 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
136 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) { |
|
137 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
134 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
135 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
136 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) { |
|
137 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
138 | 138 | if ($routeDocumentationChanged === false || $this->option('force')) { |
139 | 139 | if ($routeDocumentationChanged) { |
140 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
140 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
141 | 141 | } |
142 | 142 | } else { |
143 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
143 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
144 | 144 | $route['modified_output'] = $routeMatch[0]; |
145 | 145 | } |
146 | 146 | } |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | ->with('frontmatter', $frontmatter) |
158 | 158 | ->with('infoText', $infoText) |
159 | 159 | ->with('outputPath', $this->option('output')) |
160 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
160 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
161 | 161 | ->with('parsedRoutes', $parsedRouteOutput); |
162 | 162 | |
163 | - if (! is_dir($outputPath)) { |
|
163 | + if (!is_dir($outputPath)) { |
|
164 | 164 | $documentarian->create($outputPath); |
165 | 165 | } |
166 | 166 | |
@@ -173,23 +173,23 @@ discard block |
||
173 | 173 | ->with('frontmatter', $frontmatter) |
174 | 174 | ->with('infoText', $infoText) |
175 | 175 | ->with('outputPath', $this->option('output')) |
176 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
176 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
177 | 177 | ->with('parsedRoutes', $parsedRouteOutput); |
178 | 178 | |
179 | 179 | file_put_contents($compareFile, $compareMarkdown); |
180 | 180 | |
181 | - $this->info('Wrote index.md to: '.$outputPath); |
|
181 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
182 | 182 | |
183 | 183 | $this->info('Generating API HTML code'); |
184 | 184 | |
185 | 185 | $documentarian->generate($outputPath); |
186 | 186 | |
187 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/public/index.html'); |
|
187 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/public/index.html'); |
|
188 | 188 | |
189 | 189 | if ($this->option('noPostmanCollection') !== true) { |
190 | 190 | $this->info('Generating Postman collection'); |
191 | 191 | |
192 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
192 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | private function setUserToBeImpersonated($actAs) |
219 | 219 | { |
220 | - if (! empty($actAs)) { |
|
220 | + if (!empty($actAs)) { |
|
221 | 221 | if (version_compare($this->laravel->version(), '5.2.0', '<')) { |
222 | 222 | $userModel = config('auth.model'); |
223 | 223 | $user = $userModel::find((int) $actAs); |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | if (in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $generator->getUri($route)) || in_array($middleware, $route->middleware())) { |
260 | 260 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
261 | 261 | $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse); |
262 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
262 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
263 | 263 | } else { |
264 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
264 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | } |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | if (empty($allowedRoutes) || in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->uri()) || in_array($middleware, $route->middleware())) { |
287 | 287 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
288 | 288 | $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse); |
289 | - $this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->uri()); |
|
289 | + $this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri()); |
|
290 | 290 | } else { |
291 | - $this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->uri()); |
|
291 | + $this->warn('Skipping route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri()); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | private function isValidRoute($route) |
305 | 305 | { |
306 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
306 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $phpdoc = new DocBlock($comment); |
321 | 321 | |
322 | 322 | return collect($phpdoc->getTags()) |
323 | - ->filter(function ($tag) use ($route) { |
|
323 | + ->filter(function($tag) use ($route) { |
|
324 | 324 | return $tag->getName() === 'hideFromAPIDocumentation'; |
325 | 325 | }) |
326 | 326 | ->isEmpty(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $routeDescription = $this->getRouteDescription($routeAction['uses']); |
31 | 31 | |
32 | 32 | return $this->getParameters([ |
33 | - 'id' => md5($route->uri().':'.implode($route->getMethods())), |
|
33 | + 'id' => md5($route->uri() . ':' . implode($route->getMethods())), |
|
34 | 34 | 'resource' => $routeGroup, |
35 | 35 | 'title' => $routeDescription['short'], |
36 | 36 | 'description' => $routeDescription['long'], |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $dispatcher = app('Dingo\Api\Dispatcher')->raw(); |
63 | 63 | |
64 | - collect($server)->map(function ($key, $value) use ($dispatcher) { |
|
64 | + collect($server)->map(function($key, $value) use ($dispatcher) { |
|
65 | 65 | $dispatcher->header($value, $key); |
66 | 66 | }); |
67 | 67 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | protected function getDefaultNamespace($rootNamespace) |
37 | 37 | { |
38 | - return $rootNamespace.'\Api\Responses'; |
|
38 | + return $rootNamespace . '\Api\Responses'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -45,6 +45,6 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected function getStub() |
47 | 47 | { |
48 | - return __DIR__.'/stubs/response.stub'; |
|
48 | + return __DIR__ . '/stubs/response.stub'; |
|
49 | 49 | } |
50 | 50 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | foreach ($reflectionMethod->getParameters() as $parameter) { |
94 | 94 | $parameterType = $parameter->getClass(); |
95 | - if (! is_null($parameterType) && class_exists($parameterType->name)) { |
|
95 | + if (!is_null($parameterType) && class_exists($parameterType->name)) { |
|
96 | 96 | $className = $parameterType->name; |
97 | 97 | |
98 | 98 | if (is_subclass_of($className, FormRequest::class)) { |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | break; |
177 | 177 | case 'between': |
178 | - if (! isset($attributeData['type'])) { |
|
178 | + if (!isset($attributeData['type'])) { |
|
179 | 179 | $attributeData['type'] = 'numeric'; |
180 | 180 | } |
181 | 181 | $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription(); |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | */ |
379 | 379 | protected function fancyImplode($arr, $first, $last) |
380 | 380 | { |
381 | - $arr = array_map(function ($value) { |
|
382 | - return '`'.$value.'`'; |
|
381 | + $arr = array_map(function($value) { |
|
382 | + return '`' . $value . '`'; |
|
383 | 383 | }, $arr); |
384 | 384 | array_push($arr, implode($last, array_splice($arr, -2))); |
385 | 385 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | protected function splitValuePairs($parameters, $first = 'is ', $last = 'or ') |
390 | 390 | { |
391 | 391 | $attribute = ''; |
392 | - collect($parameters)->map(function ($item, $key) use (&$attribute, $first, $last) { |
|
393 | - $attribute .= '`'.$item.'` '; |
|
392 | + collect($parameters)->map(function($item, $key) use (&$attribute, $first, $last) { |
|
393 | + $attribute .= '`' . $item . '` '; |
|
394 | 394 | if (($key + 1) % 2 === 0) { |
395 | 395 | $attribute .= $last; |
396 | 396 | } else { |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | $methods = $this->getMethods($route); |
417 | 417 | |
418 | 418 | // Split headers into key - value pairs |
419 | - $headers = collect($headers)->map(function ($value) { |
|
419 | + $headers = collect($headers)->map(function($value) { |
|
420 | 420 | $split = explode(':', $value); |
421 | 421 | |
422 | 422 | return [trim($split[0]) => trim($split[1])]; |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | { |
439 | 439 | $uri = $this->getUri($route); |
440 | 440 | foreach ($bindings as $model => $id) { |
441 | - $uri = str_replace('{'.$model.'}', $id, $uri); |
|
441 | + $uri = str_replace('{' . $model . '}', $id, $uri); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | return $uri; |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | foreach ($headers as $name => $value) { |
540 | 540 | $name = strtr(strtoupper($name), '-', '_'); |
541 | 541 | |
542 | - if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
543 | - $name = $prefix.$name; |
|
542 | + if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
543 | + $name = $prefix . $name; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | $server[$name] = $value; |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | { |
575 | 575 | $names = \array_wrap($names); |
576 | 576 | |
577 | - return \array_filter($tags, function ($tag) use ($names) { |
|
578 | - if (! ($tag instanceof Tag)) { |
|
577 | + return \array_filter($tags, function($tag) use ($names) { |
|
578 | + if (!($tag instanceof Tag)) { |
|
579 | 579 | return false; |
580 | 580 | } |
581 | 581 |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function toArray() |
146 | 146 | { |
147 | - return array_map(function ($value) { |
|
147 | + return array_map(function($value) { |
|
148 | 148 | return $value instanceof Arrayable ? $value->toArray() : $value; |
149 | 149 | }, $this->response()); |
150 | 150 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function jsonSerialize() |
180 | 180 | { |
181 | - return array_map(function ($value) { |
|
181 | + return array_map(function($value) { |
|
182 | 182 | if ($value instanceof JsonSerializable) { |
183 | 183 | return $value->jsonSerialize(); |
184 | 184 | } elseif ($value instanceof Jsonable) { |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | $response->setData($this->toArray()); |
209 | 209 | |
210 | 210 | if (is_int($statusCode)) { |
211 | - $statusCode = function (JsonResponse $response) use ($statusCode) { |
|
211 | + $statusCode = function(JsonResponse $response) use ($statusCode) { |
|
212 | 212 | return $response->setStatusCode($statusCode); |
213 | 213 | }; |
214 | 214 | } |
215 | 215 | |
216 | 216 | if (is_array($headers)) { |
217 | - $headers = function (JsonResponse $response) use ($headers) { |
|
217 | + $headers = function(JsonResponse $response) use ($headers) { |
|
218 | 218 | return $response->withHeaders($headers); |
219 | 219 | }; |
220 | 220 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function __call($name, $arguments) |
242 | 242 | { |
243 | - if (! method_exists($this, $name)) { |
|
243 | + if (!method_exists($this, $name)) { |
|
244 | 244 | return $this->getData()->$name(...$arguments); |
245 | 245 | } |
246 | 246 |