@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $generator = new Generator($this->docConfig); |
74 | 74 | $parsedRoutes = $this->processRoutes($generator, $routes); |
75 | 75 | $parsedRoutes = collect($parsedRoutes)->groupBy('group') |
76 | - ->sortBy(static function ($group) { |
|
76 | + ->sortBy(static function($group) { |
|
77 | 77 | /* @var $group Collection */ |
78 | 78 | return $group->first()['group']; |
79 | 79 | }, SORT_NATURAL); |
@@ -89,19 +89,19 @@ discard block |
||
89 | 89 | private function writeMarkdown($parsedRoutes) |
90 | 90 | { |
91 | 91 | $outputPath = $this->docConfig->get('output'); |
92 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
93 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
94 | - $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md'; |
|
95 | - $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md'; |
|
92 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
93 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
94 | + $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md'; |
|
95 | + $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md'; |
|
96 | 96 | |
97 | 97 | $infoText = view('apidoc::partials.info') |
98 | 98 | ->with('outputPath', ltrim($outputPath, 'public/')) |
99 | 99 | ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection()); |
100 | 100 | |
101 | 101 | $settings = ['languages' => $this->docConfig->get('example_languages')]; |
102 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) use ($settings) { |
|
103 | - return $routeGroup->map(function ($route) use ($settings) { |
|
104 | - if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) { |
|
102 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) use ($settings) { |
|
103 | + return $routeGroup->map(function($route) use ($settings) { |
|
104 | + if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) { |
|
105 | 105 | $route['headers']['Content-Type'] = 'application/json'; |
106 | 106 | } |
107 | 107 | $route['output'] = (string) view('apidoc::partials.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, $existingRouteDoc)) { |
|
134 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[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, $existingRouteDoc)) { |
|
134 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[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'] = $existingRouteDoc[0]; |
142 | 142 | } |
143 | 143 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | $prependFileContents = file_exists($prependFile) |
151 | - ? file_get_contents($prependFile)."\n" : ''; |
|
151 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
152 | 152 | $appendFileContents = file_exists($appendFile) |
153 | - ? "\n".file_get_contents($appendFile) : ''; |
|
153 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
154 | 154 | |
155 | 155 | $documentarian = new Documentarian(); |
156 | 156 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection()) |
165 | 165 | ->with('parsedRoutes', $parsedRouteOutput); |
166 | 166 | |
167 | - if (! is_dir($outputPath)) { |
|
167 | + if (!is_dir($outputPath)) { |
|
168 | 168 | $documentarian->create($outputPath); |
169 | 169 | } |
170 | 170 | |
@@ -184,24 +184,24 @@ discard block |
||
184 | 184 | |
185 | 185 | file_put_contents($compareFile, $compareMarkdown); |
186 | 186 | |
187 | - $this->info('Wrote index.md to: '.$outputPath); |
|
187 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
188 | 188 | |
189 | 189 | $this->info('Generating API HTML code'); |
190 | 190 | |
191 | 191 | $documentarian->generate($outputPath); |
192 | 192 | |
193 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
193 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
194 | 194 | |
195 | 195 | if ($this->shouldGeneratePostmanCollection()) { |
196 | 196 | $this->info('Generating Postman collection'); |
197 | 197 | |
198 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
198 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | if ($logo = $this->docConfig->get('logo')) { |
202 | 202 | copy( |
203 | 203 | $logo, |
204 | - $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png' |
|
204 | + $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png' |
|
205 | 205 | ); |
206 | 206 | } |
207 | 207 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | /** @var Route $route */ |
221 | 221 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction())) { |
222 | 222 | $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']); |
223 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
223 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
224 | 224 | } else { |
225 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
225 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $action = implode('@', $action); |
242 | 242 | } |
243 | 243 | |
244 | - return ! is_callable($action) && ! is_null($action); |
|
244 | + return !is_callable($action) && !is_null($action); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | list($class, $method) = Utils::getRouteActionUses($action); |
257 | 257 | $reflection = new ReflectionClass($class); |
258 | 258 | |
259 | - if (! $reflection->hasMethod($method)) { |
|
259 | + if (!$reflection->hasMethod($method)) { |
|
260 | 260 | return false; |
261 | 261 | } |
262 | 262 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $phpdoc = new DocBlock($comment); |
267 | 267 | |
268 | 268 | return collect($phpdoc->getTags()) |
269 | - ->filter(function ($tag) use ($action) { |
|
269 | + ->filter(function($tag) use ($action) { |
|
270 | 270 | return $tag->getName() === 'hideFromAPIDocumentation'; |
271 | 271 | }) |
272 | 272 | ->isEmpty(); |
@@ -68,7 +68,7 @@ |
||
68 | 68 | |
69 | 69 | public static function deleteDirectoryAndContents($dir) |
70 | 70 | { |
71 | - $adapter = new Local(realpath(__DIR__.'/../../')); |
|
71 | + $adapter = new Local(realpath(__DIR__ . '/../../')); |
|
72 | 72 | $fs = new Filesystem($adapter); |
73 | 73 | $fs->deleteDir($dir); |
74 | 74 | } |
@@ -41,32 +41,32 @@ discard block |
||
41 | 41 | $collection = [ |
42 | 42 | 'variables' => [], |
43 | 43 | 'info' => [ |
44 | - 'name' => config('apidoc.postman.name') ?: config('app.name').' API', |
|
44 | + 'name' => config('apidoc.postman.name') ?: config('app.name') . ' API', |
|
45 | 45 | '_postman_id' => Uuid::uuid4()->toString(), |
46 | 46 | 'description' => config('apidoc.postman.description') ?: '', |
47 | 47 | 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json', |
48 | 48 | ], |
49 | - 'item' => $this->routeGroups->map(function ($routes, $groupName) { |
|
49 | + 'item' => $this->routeGroups->map(function($routes, $groupName) { |
|
50 | 50 | return [ |
51 | 51 | 'name' => $groupName, |
52 | 52 | 'description' => '', |
53 | - 'item' => $routes->map(function ($route) { |
|
53 | + 'item' => $routes->map(function($route) { |
|
54 | 54 | $mode = $route['methods'][0] === 'PUT' ? 'urlencoded' : 'formdata'; |
55 | 55 | |
56 | 56 | return [ |
57 | 57 | 'name' => $route['title'] != '' ? $route['title'] : url($route['uri']), |
58 | 58 | 'request' => [ |
59 | - 'url' => url($route['uri']).(collect($route['queryParameters'])->isEmpty() |
|
59 | + 'url' => url($route['uri']) . (collect($route['queryParameters'])->isEmpty() |
|
60 | 60 | ? '' |
61 | - : ('?'.implode('&', collect($route['queryParameters'])->map(function ($parameter, $key) { |
|
62 | - return urlencode($key).'='.urlencode($parameter['value'] ?? ''); |
|
61 | + : ('?' . implode('&', collect($route['queryParameters'])->map(function($parameter, $key) { |
|
62 | + return urlencode($key) . '=' . urlencode($parameter['value'] ?? ''); |
|
63 | 63 | })->all()))), |
64 | 64 | 'method' => $route['methods'][0], |
65 | 65 | 'header' => collect($route['headers']) |
66 | 66 | ->union([ |
67 | 67 | 'Accept' => 'application/json', |
68 | 68 | ]) |
69 | - ->map(function ($value, $header) { |
|
69 | + ->map(function($value, $header) { |
|
70 | 70 | return [ |
71 | 71 | 'key' => $header, |
72 | 72 | 'value' => $value, |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ->values()->all(), |
76 | 76 | 'body' => [ |
77 | 77 | 'mode' => $mode, |
78 | - $mode => collect($route['bodyParameters'])->map(function ($parameter, $key) { |
|
78 | + $mode => collect($route['bodyParameters'])->map(function($parameter, $key) { |
|
79 | 79 | return [ |
80 | 80 | 'key' => $key, |
81 | 81 | 'value' => $parameter['value'] ?? '', |