@@ -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; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $routePrefixes = explode(",", $routePrefix); |
83 | 83 | |
84 | - $parsedRoutes = []; |
|
84 | + $parsedRoutes = []; |
|
85 | 85 | |
86 | 86 | if ($this->option('router') === 'laravel') { |
87 | 87 | foreach ($routePrefixes as $routePrefix) { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $parsedRoutes += $this->processDingoRoutes($generator, $allowedRoutes, $routePrefix, $middleware); |
93 | 93 | } |
94 | 94 | } |
95 | - $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function ($a, $b) { |
|
95 | + $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function($a, $b) { |
|
96 | 96 | return strcmp($a->first()['resource'], $b->first()['resource']); |
97 | 97 | }); |
98 | 98 | |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | private function writeMarkdown($parsedRoutes) |
108 | 108 | { |
109 | 109 | $outputPath = $this->option('output'); |
110 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
111 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
110 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
111 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
112 | 112 | |
113 | 113 | $infoText = view('apidoc::partials.info') |
114 | 114 | ->with('outputPath', ltrim($outputPath, 'public/')) |
115 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')); |
|
115 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')); |
|
116 | 116 | |
117 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
118 | - return $routeGroup->map(function ($route) { |
|
117 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
118 | + return $routeGroup->map(function($route) { |
|
119 | 119 | $route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route)->render(); |
120 | 120 | |
121 | 121 | return $route; |
@@ -139,16 +139,16 @@ discard block |
||
139 | 139 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
140 | 140 | } |
141 | 141 | |
142 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
143 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
144 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) { |
|
145 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
142 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
143 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
144 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) { |
|
145 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
146 | 146 | if ($routeDocumentationChanged === false || $this->option('force')) { |
147 | 147 | if ($routeDocumentationChanged) { |
148 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
148 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
149 | 149 | } |
150 | 150 | } else { |
151 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
151 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
152 | 152 | $route['modified_output'] = $routeMatch[0]; |
153 | 153 | } |
154 | 154 | } |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | ->with('frontmatter', $frontmatter) |
166 | 166 | ->with('infoText', $infoText) |
167 | 167 | ->with('outputPath', $this->option('output')) |
168 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
168 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
169 | 169 | ->with('parsedRoutes', $parsedRouteOutput); |
170 | 170 | |
171 | - if (! is_dir($outputPath)) { |
|
171 | + if (!is_dir($outputPath)) { |
|
172 | 172 | $documentarian->create($outputPath); |
173 | 173 | } |
174 | 174 | |
@@ -181,23 +181,23 @@ discard block |
||
181 | 181 | ->with('frontmatter', $frontmatter) |
182 | 182 | ->with('infoText', $infoText) |
183 | 183 | ->with('outputPath', $this->option('output')) |
184 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
184 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
185 | 185 | ->with('parsedRoutes', $parsedRouteOutput); |
186 | 186 | |
187 | 187 | file_put_contents($compareFile, $compareMarkdown); |
188 | 188 | |
189 | - $this->info('Wrote index.md to: '.$outputPath); |
|
189 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
190 | 190 | |
191 | 191 | $this->info('Generating API HTML code'); |
192 | 192 | |
193 | 193 | $documentarian->generate($outputPath); |
194 | 194 | |
195 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/public/index.html'); |
|
195 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/public/index.html'); |
|
196 | 196 | |
197 | 197 | if ($this->option('noPostmanCollection') !== true) { |
198 | 198 | $this->info('Generating Postman collection'); |
199 | 199 | |
200 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
200 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | private function setUserToBeImpersonated($actAs) |
227 | 227 | { |
228 | - if (! empty($actAs)) { |
|
228 | + if (!empty($actAs)) { |
|
229 | 229 | if (version_compare($this->laravel->version(), '5.2.0', '<')) { |
230 | 230 | $userModel = config('auth.model'); |
231 | 231 | $user = $userModel::find((int) $actAs); |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | if (in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $generator->getUri($route)) || in_array($middleware, $route->middleware())) { |
268 | 268 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
269 | 269 | $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse); |
270 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
270 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
271 | 271 | } else { |
272 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
272 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | if (empty($allowedRoutes) || in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->uri()) || in_array($middleware, $route->middleware())) { |
295 | 295 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
296 | 296 | $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse); |
297 | - $this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->uri()); |
|
297 | + $this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri()); |
|
298 | 298 | } else { |
299 | - $this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->uri()); |
|
299 | + $this->warn('Skipping route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri()); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | private function isValidRoute($route) |
313 | 313 | { |
314 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
314 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $phpdoc = new DocBlock($comment); |
329 | 329 | |
330 | 330 | return collect($phpdoc->getTags()) |
331 | - ->filter(function ($tag) use ($route) { |
|
331 | + ->filter(function($tag) use ($route) { |
|
332 | 332 | return $tag->getName() === 'hideFromAPIDocumentation'; |
333 | 333 | }) |
334 | 334 | ->isEmpty(); |