@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $parsedRoutes = $this->processRoutes($generator, $routes); |
85 | 85 | $groupedRoutes = collect($parsedRoutes) |
86 | 86 | ->groupBy('groupName') |
87 | - ->sortBy(static function ($group) { |
|
87 | + ->sortBy(static function($group) { |
|
88 | 88 | /* @var $group Collection */ |
89 | 89 | return $group->first()['groupName']; |
90 | 90 | }, SORT_NATURAL); |
@@ -100,19 +100,19 @@ discard block |
||
100 | 100 | private function writeMarkdown($parsedRoutes) |
101 | 101 | { |
102 | 102 | $outputPath = $this->docConfig->get('output'); |
103 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
104 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
105 | - $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md'; |
|
106 | - $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md'; |
|
103 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
104 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
105 | + $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md'; |
|
106 | + $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md'; |
|
107 | 107 | |
108 | 108 | $infoText = view('apidoc::partials.info') |
109 | 109 | ->with('outputPath', ltrim($outputPath, 'public/')) |
110 | 110 | ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection()); |
111 | 111 | |
112 | 112 | $settings = ['languages' => $this->docConfig->get('example_languages')]; |
113 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) use ($settings) { |
|
114 | - return $routeGroup->map(function ($route) use ($settings) { |
|
115 | - if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) { |
|
113 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) use ($settings) { |
|
114 | + return $routeGroup->map(function($route) use ($settings) { |
|
115 | + if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) { |
|
116 | 116 | $route['headers']['Content-Type'] = 'application/json'; |
117 | 117 | } |
118 | 118 | $route['output'] = (string) view('apidoc::partials.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, $existingRouteDoc)) { |
|
145 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[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, $existingRouteDoc)) { |
|
145 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[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'] = $existingRouteDoc[0]; |
153 | 153 | } |
154 | 154 | } |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | $prependFileContents = file_exists($prependFile) |
162 | - ? file_get_contents($prependFile)."\n" : ''; |
|
162 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
163 | 163 | $appendFileContents = file_exists($appendFile) |
164 | - ? "\n".file_get_contents($appendFile) : ''; |
|
164 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
165 | 165 | |
166 | 166 | $documentarian = new Documentarian(); |
167 | 167 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection()) |
176 | 176 | ->with('parsedRoutes', $parsedRouteOutput); |
177 | 177 | |
178 | - if (! is_dir($outputPath)) { |
|
178 | + if (!is_dir($outputPath)) { |
|
179 | 179 | $documentarian->create($outputPath); |
180 | 180 | } |
181 | 181 | |
@@ -195,24 +195,24 @@ discard block |
||
195 | 195 | |
196 | 196 | file_put_contents($compareFile, $compareMarkdown); |
197 | 197 | |
198 | - $this->info('Wrote index.md to: '.$outputPath); |
|
198 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
199 | 199 | |
200 | 200 | $this->info('Generating API HTML code'); |
201 | 201 | |
202 | 202 | $documentarian->generate($outputPath); |
203 | 203 | |
204 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
204 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
205 | 205 | |
206 | 206 | if ($this->shouldGeneratePostmanCollection()) { |
207 | 207 | $this->info('Generating Postman collection'); |
208 | 208 | |
209 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
209 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | if ($logo = $this->docConfig->get('logo')) { |
213 | 213 | copy( |
214 | 214 | $logo, |
215 | - $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png' |
|
215 | + $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png' |
|
216 | 216 | ); |
217 | 217 | } |
218 | 218 | } |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | /** @var Route $route */ |
232 | 232 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction())) { |
233 | 233 | $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']); |
234 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
234 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
235 | 235 | } else { |
236 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
236 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $action = implode('@', $action); |
253 | 253 | } |
254 | 254 | |
255 | - return ! is_callable($action) && ! is_null($action); |
|
255 | + return !is_callable($action) && !is_null($action); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | list($class, $method) = Utils::getRouteActionUses($action); |
268 | 268 | $reflection = new ReflectionClass($class); |
269 | 269 | |
270 | - if (! $reflection->hasMethod($method)) { |
|
270 | + if (!$reflection->hasMethod($method)) { |
|
271 | 271 | return false; |
272 | 272 | } |
273 | 273 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $phpdoc = new DocBlock($comment); |
278 | 278 | |
279 | 279 | return collect($phpdoc->getTags()) |
280 | - ->filter(function ($tag) { |
|
280 | + ->filter(function($tag) { |
|
281 | 281 | return $tag->getName() === 'hideFromAPIDocumentation'; |
282 | 282 | }) |
283 | 283 | ->isEmpty(); |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | // for each ruleset in the config file. Not a high priority, though. |
54 | 54 | private function getAllRoutes(bool $usingDingoRouter, array $versions = []) |
55 | 55 | { |
56 | - if (! $usingDingoRouter) { |
|
56 | + if (!$usingDingoRouter) { |
|
57 | 57 | return RouteFacade::getRoutes(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes(); |
61 | 61 | |
62 | 62 | return collect($allRouteCollections) |
63 | - ->flatMap(function (RouteCollection $collection) { |
|
63 | + ->flatMap(function(RouteCollection $collection) { |
|
64 | 64 | return $collection->getRoutes(); |
65 | 65 | })->toArray(); |
66 | 66 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter) |
69 | 69 | { |
70 | 70 | $matchesVersion = $usingDingoRouter |
71 | - ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
71 | + ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
72 | 72 | : true; |
73 | 73 | |
74 | 74 | return str_is($mustIncludes, $route->getName()) |
@@ -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' => $routeTitle ?: $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 | |
@@ -344,25 +344,25 @@ discard block |
||
344 | 344 | $faker->seed($this->config->get('faker_seed')); |
345 | 345 | } |
346 | 346 | $fakeFactories = [ |
347 | - 'integer' => function () use ($faker) { |
|
347 | + 'integer' => function() use ($faker) { |
|
348 | 348 | return $faker->numberBetween(1, 20); |
349 | 349 | }, |
350 | - 'number' => function () use ($faker) { |
|
350 | + 'number' => function() use ($faker) { |
|
351 | 351 | return $faker->randomFloat(); |
352 | 352 | }, |
353 | - 'float' => function () use ($faker) { |
|
353 | + 'float' => function() use ($faker) { |
|
354 | 354 | return $faker->randomFloat(); |
355 | 355 | }, |
356 | - 'boolean' => function () use ($faker) { |
|
356 | + 'boolean' => function() use ($faker) { |
|
357 | 357 | return $faker->boolean(); |
358 | 358 | }, |
359 | - 'string' => function () use ($faker) { |
|
359 | + 'string' => function() use ($faker) { |
|
360 | 360 | return $faker->word; |
361 | 361 | }, |
362 | - 'array' => function () { |
|
362 | + 'array' => function() { |
|
363 | 363 | return []; |
364 | 364 | }, |
365 | - 'object' => function () { |
|
365 | + 'object' => function() { |
|
366 | 366 | return new \stdClass; |
367 | 367 | }, |
368 | 368 | ]; |