Completed
Pull Request — master (#516)
by
unknown
01:33
created
src/Tools/Utils.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
         if ($action['uses'] !== null) {
20 20
             if (is_array($action['uses'])) {
21 21
                 return $action['uses'];
22
-            }
23
-            elseif (is_string($action['uses'])) {
22
+            } elseif (is_string($action['uses'])) {
24 23
                 return explode('@', $action['uses']);
25 24
             }
26 25
         }
Please login to merge, or discard this patch.
src/Commands/GenerateDocumentation.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $generator = new Generator(config('apidoc.faker_seed'));
65 65
         $parsedRoutes = $this->processRoutes($generator, $routes);
66 66
         $parsedRoutes = collect($parsedRoutes)->groupBy('group')
67
-            ->sortBy(static function ($group) {
67
+            ->sortBy(static function($group) {
68 68
                 /* @var $group Collection */
69 69
                 return $group->first()['group'];
70 70
             }, SORT_NATURAL);
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
     private function writeMarkdown($parsedRoutes)
81 81
     {
82 82
         $outputPath = config('apidoc.output');
83
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
84
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
85
-        $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md';
86
-        $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md';
83
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
84
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
85
+        $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md';
86
+        $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md';
87 87
 
88 88
         $infoText = view('apidoc::partials.info')
89 89
             ->with('outputPath', ltrim($outputPath, 'public/'))
90 90
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection());
91 91
 
92 92
         $settings = ['languages' => config('apidoc.example_languages')];
93
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) use ($settings) {
94
-            return $routeGroup->map(function ($route) use ($settings) {
95
-                if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) {
93
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) use ($settings) {
94
+            return $routeGroup->map(function($route) use ($settings) {
95
+                if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) {
96 96
                     $route['headers']['Content-Type'] = 'application/json';
97 97
                 }
98 98
                 $route['output'] = (string) view('apidoc::partials.route')
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
119 119
             }
120 120
 
121
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
122
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
123
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) {
124
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
121
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
122
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
123
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) {
124
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
125 125
                         if ($routeDocumentationChanged === false || $this->option('force')) {
126 126
                             if ($routeDocumentationChanged) {
127
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
127
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
128 128
                             }
129 129
                         } else {
130
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
130
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
131 131
                             $route['modified_output'] = $existingRouteDoc[0];
132 132
                         }
133 133
                     }
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
         }
139 139
 
140 140
         $prependFileContents = file_exists($prependFile)
141
-            ? file_get_contents($prependFile)."\n" : '';
141
+            ? file_get_contents($prependFile) . "\n" : '';
142 142
         $appendFileContents = file_exists($appendFile)
143
-            ? "\n".file_get_contents($appendFile) : '';
143
+            ? "\n" . file_get_contents($appendFile) : '';
144 144
 
145 145
         $documentarian = new Documentarian();
146 146
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection())
155 155
             ->with('parsedRoutes', $parsedRouteOutput);
156 156
 
157
-        if (! is_dir($outputPath)) {
157
+        if (!is_dir($outputPath)) {
158 158
             $documentarian->create($outputPath);
159 159
         }
160 160
 
@@ -174,24 +174,24 @@  discard block
 block discarded – undo
174 174
 
175 175
         file_put_contents($compareFile, $compareMarkdown);
176 176
 
177
-        $this->info('Wrote index.md to: '.$outputPath);
177
+        $this->info('Wrote index.md to: ' . $outputPath);
178 178
 
179 179
         $this->info('Generating API HTML code');
180 180
 
181 181
         $documentarian->generate($outputPath);
182 182
 
183
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
183
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
184 184
 
185 185
         if ($this->shouldGeneratePostmanCollection()) {
186 186
             $this->info('Generating Postman collection');
187 187
 
188
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
188
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
189 189
         }
190 190
 
191 191
         if ($logo = config('apidoc.logo')) {
192 192
             copy(
193 193
                 $logo,
194
-                $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png'
194
+                $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png'
195 195
             );
196 196
         }
197 197
     }
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
             /** @var Route $route */
211 211
             if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction())) {
212 212
                 $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']);
213
-                $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
213
+                $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
214 214
             } else {
215
-                $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
215
+                $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
216 216
             }
217 217
         }
218 218
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
             $action = implode('@', $action);
232 232
         }
233 233
 
234
-        return ! is_callable($action) && ! is_null($action);
234
+        return !is_callable($action) && !is_null($action);
235 235
     }
236 236
 
237 237
     /**
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         list($class, $method) = Utils::getRouteActionUses($action);
247 247
         $reflection = new ReflectionClass($class);
248 248
 
249
-        if (! $reflection->hasMethod($method)) {
249
+        if (!$reflection->hasMethod($method)) {
250 250
             return false;
251 251
         }
252 252
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
             $phpdoc = new DocBlock($comment);
257 257
 
258 258
             return collect($phpdoc->getTags())
259
-                ->filter(function ($tag) use ($action) {
259
+                ->filter(function($tag) use ($action) {
260 260
                     return $tag->getName() === 'hideFromAPIDocumentation';
261 261
                 })
262 262
                 ->isEmpty();
Please login to merge, or discard this patch.