@@ -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 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @param Route $route |
14 | - * @return mixed |
|
14 | + * @return string |
|
15 | 15 | */ |
16 | 16 | protected function getUri(Route $route) |
17 | 17 | { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | return $this->getParameters([ |
48 | - 'id' => md5($route->getUri().':'.implode($route->getMethods())), |
|
48 | + 'id' => md5($route->getUri() . ':' . implode($route->getMethods())), |
|
49 | 49 | 'resource' => $routeGroup, |
50 | 50 | 'title' => $routeDescription['short'], |
51 | 51 | 'description' => $routeDescription['long'], |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | $kernel->terminate($request, $response); |
100 | 100 | |
101 | - if (file_exists($file = App::bootstrapPath().'/app.php')) { |
|
101 | + if (file_exists($file = App::bootstrapPath() . '/app.php')) { |
|
102 | 102 | $app = require $file; |
103 | 103 | $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); |
104 | 104 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | foreach ($reflectionMethod->getParameters() as $parameter) { |
122 | 122 | $parameterType = $parameter->getClass(); |
123 | - if (! is_null($parameterType) && class_exists($parameterType->name)) { |
|
123 | + if (!is_null($parameterType) && class_exists($parameterType->name)) { |
|
124 | 124 | $className = $parameterType->name; |
125 | 125 | |
126 | 126 | if (is_subclass_of($className, FormRequest::class)) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * @param $route |
|
56 | + * @param \Illuminate\Routing\Route $route |
|
57 | 57 | * |
58 | 58 | * @return \Illuminate\Http\Response |
59 | 59 | */ |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param string $rule |
411 | 411 | * @param string $parameter |
412 | 412 | * |
413 | - * @return array |
|
413 | + * @return string |
|
414 | 414 | */ |
415 | 415 | protected function parseParameters($rule, $parameter) |
416 | 416 | { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $methods = $route->getMethods(); |
71 | 71 | |
72 | 72 | // Split headers into key - value pairs |
73 | - $headers = collect($headers)->map(function ($value) { |
|
73 | + $headers = collect($headers)->map(function($value) { |
|
74 | 74 | $split = explode(':', $value); |
75 | 75 | |
76 | 76 | return [trim($split[0]) => trim($split[1])]; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $uri = $this->getUri($route); |
91 | 91 | foreach ($bindings as $model => $id) { |
92 | - $uri = str_replace('{'.$model.'}', $id, $uri); |
|
92 | + $uri = str_replace('{' . $model . '}', $id, $uri); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $uri; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | foreach ($reflectionMethod->getParameters() as $parameter) { |
153 | 153 | $parameterType = $parameter->getClass(); |
154 | - if (! is_null($parameterType) && class_exists($parameterType->name)) { |
|
154 | + if (!is_null($parameterType) && class_exists($parameterType->name)) { |
|
155 | 155 | $className = $parameterType->name; |
156 | 156 | |
157 | 157 | if (is_subclass_of($className, FormRequest::class)) { |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | */ |
182 | 182 | protected function fancyImplode($arr, $first, $last) |
183 | 183 | { |
184 | - $arr = array_map(function ($value) { |
|
185 | - return '`'.$value.'`'; |
|
184 | + $arr = array_map(function($value) { |
|
185 | + return '`' . $value . '`'; |
|
186 | 186 | }, $arr); |
187 | 187 | array_push($arr, implode($last, array_splice($arr, -2))); |
188 | 188 | |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | protected function splitValuePairs($parameters, $first = 'is ', $last = 'or ') |
193 | 193 | { |
194 | 194 | $attribute = ''; |
195 | - collect($parameters)->map(function ($item, $key) use (&$attribute, $first, $last) { |
|
196 | - $attribute .= '`'.$item.'` '; |
|
195 | + collect($parameters)->map(function($item, $key) use (&$attribute, $first, $last) { |
|
196 | + $attribute .= '`' . $item . '` '; |
|
197 | 197 | if (($key + 1) % 2 === 0) { |
198 | 198 | $attribute .= $last; |
199 | 199 | } else { |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | break; |
269 | 269 | case 'between': |
270 | - if (! isset($attributeData['type'])) { |
|
270 | + if (!isset($attributeData['type'])) { |
|
271 | 271 | $attributeData['type'] = 'numeric'; |
272 | 272 | } |
273 | 273 | $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription(); |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | foreach ($headers as $name => $value) { |
430 | 430 | $name = strtr(strtoupper($name), '-', '_'); |
431 | 431 | |
432 | - if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
433 | - $name = $prefix.$name; |
|
432 | + if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
433 | + $name = $prefix . $name; |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | $server[$name] = $value; |
@@ -77,7 +77,7 @@ |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | - * @param null $rule |
|
80 | + * @param string $rule |
|
81 | 81 | * |
82 | 82 | * @return static |
83 | 83 | */ |
@@ -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 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | 'description' => '', |
32 | 32 | 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json' |
33 | 33 | ], |
34 | - 'item' => $this->routeGroups->map(function ($routes, $groupName) { |
|
34 | + 'item' => $this->routeGroups->map(function($routes, $groupName) { |
|
35 | 35 | return [ |
36 | 36 | 'name' => $groupName, |
37 | 37 | 'description' => '', |
38 | - 'item' => $routes->map(function ($route) { |
|
38 | + 'item' => $routes->map(function($route) { |
|
39 | 39 | return [ |
40 | 40 | 'name' => $route['title'] != '' ? $route['title'] : url($route['uri']), |
41 | 41 | 'request' => [ |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | 'method' => $route['methods'][0], |
44 | 44 | 'body' => [ |
45 | 45 | 'mode' => 'formdata', |
46 | - 'formdata' => collect($route['parameters'])->map(function ($parameter, $key) { |
|
46 | + 'formdata' => collect($route['parameters'])->map(function($parameter, $key) { |
|
47 | 47 | return [ |
48 | 48 | 'key' => $key, |
49 | 49 | 'value' => isset($parameter['value']) ? $parameter['value'] : '', |
@@ -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['apidoc.generate'] = $this->app->share(function () { |
|
34 | + $this->app['apidoc.generate'] = $this->app->share(function() { |
|
35 | 35 | return new GenerateDocumentation(); |
36 | 36 | }); |
37 | - $this->app['apidoc.update'] = $this->app->share(function () { |
|
37 | + $this->app['apidoc.update'] = $this->app->share(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 | } |
@@ -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'], |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $dispatcher = app('Dingo\Api\Dispatcher')->raw(); |
50 | 50 | |
51 | - collect($server)->map(function ($key, $value) use ($dispatcher) { |
|
51 | + collect($server)->map(function($key, $value) use ($dispatcher) { |
|
52 | 52 | $dispatcher->header($key, $value); |
53 | 53 | }); |
54 | 54 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | * |
47 | 47 | * @param boolean $disable |
48 | 48 | * |
49 | - * @return void |
|
49 | + * @return boolean |
|
50 | 50 | */ |
51 | 51 | public function prepareMiddleware($disable = true) |
52 | 52 | { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $this->setUserToBeImpersonated($this->option('actAsUserId')); |
72 | 72 | |
73 | - if ($routePrefix === null && ! count($allowedRoutes) && $middleware === null) { |
|
73 | + if ($routePrefix === null && !count($allowedRoutes) && $middleware === null) { |
|
74 | 74 | $this->error('You must provide either a route prefix or a route or a middleware to generate the documentation.'); |
75 | 75 | |
76 | 76 | return false; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } else { |
82 | 82 | $parsedRoutes = $this->processDingoRoutes($generator, $allowedRoutes, $routePrefix, $middleware); |
83 | 83 | } |
84 | - $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function ($a, $b) { |
|
84 | + $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function($a, $b) { |
|
85 | 85 | return strcmp($a->first()['resource'], $b->first()['resource']); |
86 | 86 | }); |
87 | 87 | |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | private function writeMarkdown($parsedRoutes) |
97 | 97 | { |
98 | 98 | $outputPath = $this->option('output'); |
99 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
100 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
99 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
100 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
101 | 101 | |
102 | 102 | $infoText = view('apidoc::partials.info') |
103 | 103 | ->with('outputPath', ltrim($outputPath, 'public/')) |
104 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')); |
|
104 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')); |
|
105 | 105 | |
106 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
107 | - return $routeGroup->map(function ($route) { |
|
106 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
107 | + return $routeGroup->map(function($route) { |
|
108 | 108 | $route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route); |
109 | 109 | |
110 | 110 | return $route; |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
129 | 129 | } |
130 | 130 | |
131 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
132 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
133 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) { |
|
134 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
131 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
132 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
133 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) { |
|
134 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
135 | 135 | if ($routeDocumentationChanged === false || $this->option('force')) { |
136 | 136 | if ($routeDocumentationChanged) { |
137 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
137 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
138 | 138 | } |
139 | 139 | } else { |
140 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
140 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
141 | 141 | $route['modified_output'] = $routeMatch[0]; |
142 | 142 | } |
143 | 143 | } |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | ->with('frontmatter', $frontmatter) |
155 | 155 | ->with('infoText', $infoText) |
156 | 156 | ->with('outputPath', $this->option('output')) |
157 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
157 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
158 | 158 | ->with('parsedRoutes', $parsedRouteOutput); |
159 | 159 | |
160 | - if (! is_dir($outputPath)) { |
|
160 | + if (!is_dir($outputPath)) { |
|
161 | 161 | $documentarian->create($outputPath); |
162 | 162 | } |
163 | 163 | |
@@ -170,24 +170,24 @@ discard block |
||
170 | 170 | ->with('frontmatter', $frontmatter) |
171 | 171 | ->with('infoText', $infoText) |
172 | 172 | ->with('outputPath', $this->option('output')) |
173 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
173 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
174 | 174 | ->with('parsedRoutes', $parsedRouteOutput); |
175 | 175 | |
176 | 176 | file_put_contents($compareFile, $compareMarkdown); |
177 | 177 | |
178 | - $this->info('Wrote index.md to: '.$outputPath); |
|
178 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
179 | 179 | |
180 | 180 | $this->info('Generating API HTML code'); |
181 | 181 | |
182 | 182 | $documentarian->generate($outputPath); |
183 | 183 | |
184 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/public/index.html'); |
|
184 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/public/index.html'); |
|
185 | 185 | |
186 | 186 | |
187 | 187 | if ($this->option('noPostmanCollection') !== true) { |
188 | 188 | $this->info('Generating Postman collection'); |
189 | 189 | |
190 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
190 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | private function setUserToBeImpersonated($actAs) |
217 | 217 | { |
218 | - if (! empty($actAs)) { |
|
218 | + if (!empty($actAs)) { |
|
219 | 219 | if (version_compare($this->laravel->version(), '5.2.0', '<')) { |
220 | 220 | $userModel = config('auth.model'); |
221 | 221 | $user = $userModel::find((int) $actAs); |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | if (in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->getUri()) || in_array($middleware, $route->middleware())) { |
258 | 258 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
259 | 259 | $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse); |
260 | - $this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->getUri()); |
|
260 | + $this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->getUri()); |
|
261 | 261 | } else { |
262 | - $this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->getUri()); |
|
262 | + $this->warn('Skipping route: [' . implode(',', $route->getMethods()) . '] ' . $route->getUri()); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | if (empty($allowedRoutes) || in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->uri()) || in_array($middleware, $route->middleware())) { |
285 | 285 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
286 | 286 | $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse); |
287 | - $this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->uri()); |
|
287 | + $this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri()); |
|
288 | 288 | } else { |
289 | - $this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->uri()); |
|
289 | + $this->warn('Skipping route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri()); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | private function isValidRoute($route) |
303 | 303 | { |
304 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
304 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $phpdoc = new DocBlock($comment); |
319 | 319 | |
320 | 320 | return collect($phpdoc->getTags()) |
321 | - ->filter(function ($tag) use ($route) { |
|
321 | + ->filter(function($tag) use ($route) { |
|
322 | 322 | return $tag->getName() === 'hideFromAPIDocumentation'; |
323 | 323 | }) |
324 | 324 | ->isEmpty(); |