Completed
Push — master ( 3f418d...fe0077 )
by
unknown
08:25 queued 02:01
created
src/Tools/RouteMatcher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 
51 51
     private function getAllRoutes(bool $usingDingoRouter, array $versions = [])
52 52
     {
53
-        if (! $usingDingoRouter) {
53
+        if (!$usingDingoRouter) {
54 54
             return RouteFacade::getRoutes();
55 55
         }
56 56
 
57 57
         $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes();
58 58
 
59 59
         return collect($allRouteCollections)
60
-            ->flatMap(function (RouteCollection $collection) {
60
+            ->flatMap(function(RouteCollection $collection) {
61 61
                 return $collection->getRoutes();
62 62
             })->toArray();
63 63
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter)
66 66
     {
67 67
         $matchesVersion = $usingDingoRouter
68
-            ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
68
+            ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
69 69
             : true;
70 70
 
71 71
         return str_is($mustIncludes, $route->getName())
Please login to merge, or discard this patch.
src/Tools/ResponseResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,8 @@
 block discarded – undo
48 48
             /** @var Response[]|null $response */
49 49
             $responses = $strategy($this->route, $tags, $routeProps);
50 50
 
51
-            if (! is_null($responses)) {
52
-                return array_map(function (Response $response) {
51
+            if (!is_null($responses)) {
52
+                return array_map(function(Response $response) {
53 53
                     return ['status' => $response->getStatusCode(), 'content' => $this->getResponseContent($response)];
54 54
                 }, $responses);
55 55
             }
Please login to merge, or discard this patch.
src/Tools/ResponseStrategies/TransformerTagsStrategy.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
             $fractal = new Manager();
49 49
  
50
-            if (! is_null(config('apidoc.fractal.serializer'))) {
50
+            if (!is_null(config('apidoc.fractal.serializer'))) {
51 51
                 $fractal->setSerializer(app(config('apidoc.fractal.serializer')));
52 52
             }
53 53
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod)
81 81
     {
82
-        $modelTag = array_first(array_filter($tags, function ($tag) {
82
+        $modelTag = array_first(array_filter($tags, function($tag) {
83 83
             return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel';
84 84
         }));
85 85
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             $type = $modelTag->getContent();
89 89
         } else {
90 90
             $parameter = array_first($transformerMethod->getParameters());
91
-            if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) {
91
+            if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) {
92 92
                 // ladies and gentlemen, we have a type!
93 93
                 $type = (string) $parameter->getType();
94 94
             }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     private function getTransformerTag(array $tags)
134 134
     {
135 135
         $transFormerTags = array_values(
136
-            array_filter($tags, function ($tag) {
136
+            array_filter($tags, function($tag) {
137 137
                 return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']);
138 138
             })
139 139
         );
Please login to merge, or discard this patch.
src/ApiDocGeneratorServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@
 block discarded – undo
15 15
      */
16 16
     public function boot()
17 17
     {
18
-        $this->loadViewsFrom(__DIR__.'/../resources/views/', 'apidoc');
18
+        $this->loadViewsFrom(__DIR__ . '/../resources/views/', 'apidoc');
19 19
 
20 20
         $this->publishes([
21
-            __DIR__.'/../resources/views' => app()->basePath().'/resources/views/vendor/apidoc',
21
+            __DIR__ . '/../resources/views' => app()->basePath() . '/resources/views/vendor/apidoc',
22 22
         ], 'apidoc-views');
23 23
 
24 24
         $this->publishes([
25
-            __DIR__.'/../config/apidoc.php' => app()->basePath().'/config/apidoc.php',
25
+            __DIR__ . '/../config/apidoc.php' => app()->basePath() . '/config/apidoc.php',
26 26
         ], 'apidoc-config');
27 27
 
28
-        $this->mergeConfigFrom(__DIR__.'/../config/apidoc.php', 'apidoc');
28
+        $this->mergeConfigFrom(__DIR__ . '/../config/apidoc.php', 'apidoc');
29 29
 
30 30
         if ($this->app->runningInConsole()) {
31 31
             $this->commands([
Please login to merge, or discard this patch.
src/Commands/RebuildDocumentation.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@
 block discarded – undo
42 42
 
43 43
         $documentarian = new Documentarian();
44 44
 
45
-        if (! is_dir($outputPath)) {
46
-            $this->error('There is no existing documentation available at '.$outputPath.'.');
45
+        if (!is_dir($outputPath)) {
46
+            $this->error('There is no existing documentation available at ' . $outputPath . '.');
47 47
 
48 48
             return false;
49 49
         }
50
-        $this->info('Rebuilding API HTML code from '.$outputPath.'/source/index.md');
50
+        $this->info('Rebuilding API HTML code from ' . $outputPath . '/source/index.md');
51 51
 
52 52
         $documentarian->generate($outputPath);
53 53
 
54
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
54
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
55 55
     }
56 56
 }
Please login to merge, or discard this patch.
src/Tools/Utils.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Postman/CollectionWriter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,32 +41,32 @@  discard block
 block discarded – undo
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
 block discarded – undo
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'] ?? '',
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
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $generator = new Generator($this->docConfig);
84 84
         $parsedRoutes = $this->processRoutes($generator, $routes);
85 85
         $parsedRoutes = collect($parsedRoutes)->groupBy('groupName')
86
-            ->sortBy(static function ($group) {
86
+            ->sortBy(static function($group) {
87 87
                 /* @var $group Collection */
88 88
                 return $group->first()['groupName'];
89 89
             }, SORT_NATURAL);
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
     private function writeMarkdown($parsedRoutes)
100 100
     {
101 101
         $outputPath = $this->docConfig->get('output');
102
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
103
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
104
-        $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md';
105
-        $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md';
102
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
103
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
104
+        $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md';
105
+        $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md';
106 106
 
107 107
         $infoText = view('apidoc::partials.info')
108 108
             ->with('outputPath', ltrim($outputPath, 'public/'))
109 109
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection());
110 110
 
111 111
         $settings = ['languages' => $this->docConfig->get('example_languages')];
112
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) use ($settings) {
113
-            return $routeGroup->map(function ($route) use ($settings) {
114
-                if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) {
112
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) use ($settings) {
113
+            return $routeGroup->map(function($route) use ($settings) {
114
+                if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) {
115 115
                     $route['headers']['Content-Type'] = 'application/json';
116 116
                 }
117 117
                 $route['output'] = (string) view('apidoc::partials.route')
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
139 139
             }
140 140
 
141
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
142
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
143
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) {
144
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
141
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
142
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
143
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) {
144
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
145 145
                         if ($routeDocumentationChanged === false || $this->option('force')) {
146 146
                             if ($routeDocumentationChanged) {
147
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
147
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
148 148
                             }
149 149
                         } else {
150
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
150
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
151 151
                             $route['modified_output'] = $existingRouteDoc[0];
152 152
                         }
153 153
                     }
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
         }
159 159
 
160 160
         $prependFileContents = file_exists($prependFile)
161
-            ? file_get_contents($prependFile)."\n" : '';
161
+            ? file_get_contents($prependFile) . "\n" : '';
162 162
         $appendFileContents = file_exists($appendFile)
163
-            ? "\n".file_get_contents($appendFile) : '';
163
+            ? "\n" . file_get_contents($appendFile) : '';
164 164
 
165 165
         $documentarian = new Documentarian();
166 166
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection())
175 175
             ->with('parsedRoutes', $parsedRouteOutput);
176 176
 
177
-        if (! is_dir($outputPath)) {
177
+        if (!is_dir($outputPath)) {
178 178
             $documentarian->create($outputPath);
179 179
         }
180 180
 
@@ -194,24 +194,24 @@  discard block
 block discarded – undo
194 194
 
195 195
         file_put_contents($compareFile, $compareMarkdown);
196 196
 
197
-        $this->info('Wrote index.md to: '.$outputPath);
197
+        $this->info('Wrote index.md to: ' . $outputPath);
198 198
 
199 199
         $this->info('Generating API HTML code');
200 200
 
201 201
         $documentarian->generate($outputPath);
202 202
 
203
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
203
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
204 204
 
205 205
         if ($this->shouldGeneratePostmanCollection()) {
206 206
             $this->info('Generating Postman collection');
207 207
 
208
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
208
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
209 209
         }
210 210
 
211 211
         if ($logo = $this->docConfig->get('logo')) {
212 212
             copy(
213 213
                 $logo,
214
-                $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png'
214
+                $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png'
215 215
             );
216 216
         }
217 217
     }
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
             /** @var Route $route */
231 231
             if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction())) {
232 232
                 $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']);
233
-                $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
233
+                $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
234 234
             } else {
235
-                $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
235
+                $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
236 236
             }
237 237
         }
238 238
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
             $action = implode('@', $action);
252 252
         }
253 253
 
254
-        return ! is_callable($action) && ! is_null($action);
254
+        return !is_callable($action) && !is_null($action);
255 255
     }
256 256
 
257 257
     /**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         list($class, $method) = Utils::getRouteActionUses($action);
267 267
         $reflection = new ReflectionClass($class);
268 268
 
269
-        if (! $reflection->hasMethod($method)) {
269
+        if (!$reflection->hasMethod($method)) {
270 270
             return false;
271 271
         }
272 272
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
             $phpdoc = new DocBlock($comment);
277 277
 
278 278
             return collect($phpdoc->getTags())
279
-                ->filter(function ($tag) {
279
+                ->filter(function($tag) {
280 280
                     return $tag->getName() === 'hideFromAPIDocumentation';
281 281
                 })
282 282
                 ->isEmpty();
Please login to merge, or discard this patch.
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
             'groupName' => $routeGroupName,
74 74
             'groupDescription' => $routeGroupDescription,
75 75
             'title' => $docBlock['short'],
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -328,25 +328,25 @@  discard block
 block discarded – undo
328 328
             $faker->seed($this->config->get('faker_seed'));
329 329
         }
330 330
         $fakeFactories = [
331
-            'integer' => function () use ($faker) {
331
+            'integer' => function() use ($faker) {
332 332
                 return $faker->numberBetween(1, 20);
333 333
             },
334
-            'number' => function () use ($faker) {
334
+            'number' => function() use ($faker) {
335 335
                 return $faker->randomFloat();
336 336
             },
337
-            'float' => function () use ($faker) {
337
+            'float' => function() use ($faker) {
338 338
                 return $faker->randomFloat();
339 339
             },
340
-            'boolean' => function () use ($faker) {
340
+            'boolean' => function() use ($faker) {
341 341
                 return $faker->boolean();
342 342
             },
343
-            'string' => function () use ($faker) {
343
+            'string' => function() use ($faker) {
344 344
                 return $faker->word;
345 345
             },
346
-            'array' => function () {
346
+            'array' => function() {
347 347
                 return [];
348 348
             },
349
-            'object' => function () {
349
+            'object' => function() {
350 350
                 return new \stdClass;
351 351
             },
352 352
         ];
Please login to merge, or discard this patch.