Completed
Push — master ( 7b441b...f0c0d1 )
by
unknown
01:48 queued 10s
created
src/Tools/Generator.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
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
             'group' => $routeGroup,
74 74
             'title' => $docBlock['short'],
75 75
             'description' => $docBlock['long'],
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'cleanQueryParameters' => $this->cleanParams($queryParameters),
83 83
             'authenticated' => $this->getAuthStatusFromDocBlock($docBlock['tags']),
84 84
             'response' => $content,
85
-            'showresponse' => ! empty($content),
85
+            'showresponse' => !empty($content),
86 86
         ];
87 87
         $parsedRoute['headers'] = $rulesToApply['headers'] ?? [];
88 88
 
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
     protected function getBodyParametersFromDocBlock(array $tags)
129 129
     {
130 130
         $parameters = collect($tags)
131
-            ->filter(function ($tag) {
131
+            ->filter(function($tag) {
132 132
                 return $tag instanceof Tag && $tag->getName() === 'bodyParam';
133 133
             })
134
-            ->mapWithKeys(function ($tag) {
134
+            ->mapWithKeys(function($tag) {
135 135
                 preg_match('/(.+?)\s+(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content);
136 136
                 if (empty($content)) {
137 137
                     // this means only name and type were supplied
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
     protected function getQueryParametersFromDocBlock(array $tags)
204 204
     {
205 205
         $parameters = collect($tags)
206
-            ->filter(function ($tag) {
206
+            ->filter(function($tag) {
207 207
                 return $tag instanceof Tag && $tag->getName() === 'queryParam';
208 208
             })
209
-            ->mapWithKeys(function ($tag) {
209
+            ->mapWithKeys(function($tag) {
210 210
                 preg_match('/(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content);
211 211
                 if (empty($content)) {
212 212
                     // this means only name was supplied
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     protected function getAuthStatusFromDocBlock(array $tags)
245 245
     {
246 246
         $authTag = collect($tags)
247
-            ->first(function ($tag) {
247
+            ->first(function($tag) {
248 248
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'authenticated';
249 249
             });
250 250
 
@@ -319,25 +319,25 @@  discard block
 block discarded – undo
319 319
             $faker->seed($this->fakerSeed);
320 320
         }
321 321
         $fakeFactories = [
322
-            'integer' => function () use ($faker) {
322
+            'integer' => function() use ($faker) {
323 323
                 return $faker->numberBetween(1, 20);
324 324
             },
325
-            'number' => function () use ($faker) {
325
+            'number' => function() use ($faker) {
326 326
                 return $faker->randomFloat();
327 327
             },
328
-            'float' => function () use ($faker) {
328
+            'float' => function() use ($faker) {
329 329
                 return $faker->randomFloat();
330 330
             },
331
-            'boolean' => function () use ($faker) {
331
+            'boolean' => function() use ($faker) {
332 332
                 return $faker->boolean();
333 333
             },
334
-            'string' => function () use ($faker) {
334
+            'string' => function() use ($faker) {
335 335
                 return $faker->word;
336 336
             },
337
-            'array' => function () {
337
+            'array' => function() {
338 338
                 return [];
339 339
             },
340
-            'object' => function () {
340
+            'object' => function() {
341 341
                 return new \stdClass;
342 342
             },
343 343
         ];
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
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $generator = new Generator(config('apidoc.faker_seed'));
59 59
         $parsedRoutes = $this->processRoutes($generator, $routes);
60 60
         $parsedRoutes = collect($parsedRoutes)->groupBy('group')
61
-            ->sortBy(static function ($group) {
61
+            ->sortBy(static function($group) {
62 62
                 /* @var $group Collection */
63 63
                 return $group->first()['group'];
64 64
             }, SORT_NATURAL);
@@ -74,19 +74,19 @@  discard block
 block discarded – undo
74 74
     private function writeMarkdown($parsedRoutes)
75 75
     {
76 76
         $outputPath = config('apidoc.output');
77
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
78
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
79
-        $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md';
80
-        $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md';
77
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
78
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
79
+        $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md';
80
+        $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md';
81 81
 
82 82
         $infoText = view('apidoc::partials.info')
83 83
             ->with('outputPath', ltrim($outputPath, 'public/'))
84 84
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection());
85 85
 
86 86
         $settings = ['languages' => config('apidoc.example_languages')];
87
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) use ($settings) {
88
-            return $routeGroup->map(function ($route) use ($settings) {
89
-                if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) {
87
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) use ($settings) {
88
+            return $routeGroup->map(function($route) use ($settings) {
89
+                if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) {
90 90
                     $route['headers']['Content-Type'] = 'application/json';
91 91
                 }
92 92
                 $route['output'] = (string) view('apidoc::partials.route')
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
113 113
             }
114 114
 
115
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
116
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
117
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) {
118
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
115
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
116
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
117
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) {
118
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
119 119
                         if ($routeDocumentationChanged === false || $this->option('force')) {
120 120
                             if ($routeDocumentationChanged) {
121
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
121
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
122 122
                             }
123 123
                         } else {
124
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
124
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
125 125
                             $route['modified_output'] = $existingRouteDoc[0];
126 126
                         }
127 127
                     }
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
         }
133 133
 
134 134
         $prependFileContents = file_exists($prependFile)
135
-            ? file_get_contents($prependFile)."\n" : '';
135
+            ? file_get_contents($prependFile) . "\n" : '';
136 136
         $appendFileContents = file_exists($appendFile)
137
-            ? "\n".file_get_contents($appendFile) : '';
137
+            ? "\n" . file_get_contents($appendFile) : '';
138 138
 
139 139
         $documentarian = new Documentarian();
140 140
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection())
149 149
             ->with('parsedRoutes', $parsedRouteOutput);
150 150
 
151
-        if (! is_dir($outputPath)) {
151
+        if (!is_dir($outputPath)) {
152 152
             $documentarian->create($outputPath);
153 153
         }
154 154
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
         file_put_contents($compareFile, $compareMarkdown);
170 170
 
171
-        $this->info('Wrote index.md to: '.$outputPath);
171
+        $this->info('Wrote index.md to: ' . $outputPath);
172 172
 
173 173
         $this->info('Generating API HTML code');
174 174
 
175 175
         $documentarian->generate($outputPath);
176 176
 
177
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
177
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
178 178
 
179 179
         if ($this->shouldGeneratePostmanCollection()) {
180 180
             $this->info('Generating Postman collection');
181 181
 
182
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
182
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
183 183
         }
184 184
 
185 185
         if ($logo = config('apidoc.logo')) {
186 186
             copy(
187 187
                 $logo,
188
-                $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png'
188
+                $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png'
189 189
             );
190 190
         }
191 191
     }
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
             /** @var Route $route */
205 205
             if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
206 206
                 $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']);
207
-                $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
207
+                $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
208 208
             } else {
209
-                $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
209
+                $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
210 210
             }
211 211
         }
212 212
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     private function isValidRoute(Route $route)
222 222
     {
223
-        return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']);
223
+        return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']);
224 224
     }
225 225
 
226 226
     /**
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         list($class, $method) = explode('@', $route);
236 236
         $reflection = new ReflectionClass($class);
237 237
 
238
-        if (! $reflection->hasMethod($method)) {
238
+        if (!$reflection->hasMethod($method)) {
239 239
             return false;
240 240
         }
241 241
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             $phpdoc = new DocBlock($comment);
246 246
 
247 247
             return collect($phpdoc->getTags())
248
-                ->filter(function ($tag) use ($route) {
248
+                ->filter(function($tag) use ($route) {
249 249
                     return $tag->getName() === 'hideFromAPIDocumentation';
250 250
                 })
251 251
                 ->isEmpty();
Please login to merge, or discard this patch.