Completed
Push — master ( de38da...82368f )
by Marcel
03:56
created
src/Mpociot/ApiDoc/Commands/UpdateDocumentation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 
45 45
         $documentarian = new Documentarian();
46 46
 
47
-        if (! is_dir($outputPath)) {
48
-            $this->error('There is no generated documentation available at '.$outputPath.'.');
47
+        if (!is_dir($outputPath)) {
48
+            $this->error('There is no generated documentation available at ' . $outputPath . '.');
49 49
 
50 50
             return false;
51 51
         }
@@ -53,6 +53,6 @@  discard block
 block discarded – undo
53 53
 
54 54
         $documentarian->generate($outputPath);
55 55
 
56
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/public/index.html');
56
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/public/index.html');
57 57
     }
58 58
 }
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Generators/LaravelGenerator.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
     /**
13 13
      * @param Route $route
14
-     * @return mixed
14
+     * @return string
15 15
      */
16 16
     protected function getUri(Route $route)
17 17
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
         }
45 45
 
46 46
         return $this->getParameters([
47
-            'id' => md5($route->getUri().':'.implode($route->getMethods())),
47
+            'id' => md5($route->getUri() . ':' . implode($route->getMethods())),
48 48
             'resource' => $routeGroup,
49 49
             'title' => $routeDescription['short'],
50 50
             'description' => $routeDescription['long'],
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Generators/AbstractGenerator.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
     /**
56
-     * @param  $route
56
+     * @param  \Illuminate\Routing\Route $route
57 57
      *
58 58
      * @return \Illuminate\Http\Response
59 59
      */
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
      * @param  string  $rule
411 411
      * @param  string  $parameter
412 412
      *
413
-     * @return array
413
+     * @return string
414 414
      */
415 415
     protected function parseParameters($rule, $parameter)
416 416
     {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         $uri = $this->getUri($route);
81 81
         foreach ($bindings as $model => $id) {
82
-            $uri = str_replace('{'.$model.'}', $id, $uri);
82
+            $uri = str_replace('{' . $model . '}', $id, $uri);
83 83
         }
84 84
 
85 85
         return $uri;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
         foreach ($reflectionMethod->getParameters() as $parameter) {
143 143
             $parameterType = $parameter->getClass();
144
-            if (! is_null($parameterType) && class_exists($parameterType->name)) {
144
+            if (!is_null($parameterType) && class_exists($parameterType->name)) {
145 145
                 $className = $parameterType->name;
146 146
 
147 147
                 if (is_subclass_of($className, FormRequest::class)) {
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
      */
172 172
     protected function fancyImplode($arr, $first, $last)
173 173
     {
174
-        $arr = array_map(function ($value) {
175
-            return '`'.$value.'`';
174
+        $arr = array_map(function($value) {
175
+            return '`' . $value . '`';
176 176
         }, $arr);
177 177
         array_push($arr, implode($last, array_splice($arr, -2)));
178 178
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                 $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
236 236
                 break;
237 237
             case 'between':
238
-                if (! isset($attributeData['type'])) {
238
+                if (!isset($attributeData['type'])) {
239 239
                     $attributeData['type'] = 'numeric';
240 240
                 }
241 241
                 $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
         foreach ($headers as $name => $value) {
393 393
             $name = strtr(strtoupper($name), '-', '_');
394 394
 
395
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
396
-                $name = $prefix.$name;
395
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
396
+                $name = $prefix . $name;
397 397
             }
398 398
 
399 399
             $server[$name] = $value;
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Parsers/RuleDescriptionParser.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
     }
78 78
 
79 79
     /**
80
-     * @param null $rule
80
+     * @param string $rule
81 81
      *
82 82
      * @return static
83 83
      */
Please login to merge, or discard this patch.
Spacing   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,8 +34,7 @@  discard block
 block discarded – undo
34 34
     public function with($parameters)
35 35
     {
36 36
         is_array($parameters) ?
37
-            $this->parameters += $parameters :
38
-            $this->parameters[] = $parameters;
37
+            $this->parameters += $parameters : $this->parameters[] = $parameters;
39 38
 
40 39
         return $this;
41 40
     }
@@ -54,8 +53,7 @@  discard block
 block discarded – undo
54 53
     protected function makeDescription()
55 54
     {
56 55
         $description = trans()->hasForLocale($this->rule) ?
57
-                            trans()->get($this->rule) :
58
-                            trans()->get($this->rule, [], self::DEFAULT_LOCALE);
56
+                            trans()->get($this->rule) : trans()->get($this->rule, [], self::DEFAULT_LOCALE);
59 57
 
60 58
         return $this->replaceAttributes($description);
61 59
     }
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Postman/CollectionWriter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
                 'description' => '',
32 32
                 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json'
33 33
             ],
34
-            'item' => $this->routeGroups->map(function ($routes, $groupName) {
34
+            'item' => $this->routeGroups->map(function($routes, $groupName) {
35 35
                 return [
36 36
                     'name' => $groupName,
37 37
                     'description' => '',
38
-                    'item' => $routes->map(function ($route) {
38
+                    'item' => $routes->map(function($route) {
39 39
                         return [
40 40
                             'name' => $route['title'] != '' ? $route['title'] : url($route['uri']),
41 41
                             'request' => [
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
                                 'method' => $route['methods'][0],
44 44
                                 'body' => [
45 45
                                     'mode' => 'formdata',
46
-                                    'formdata' => collect($route['parameters'])->map(function ($parameter, $key) {
46
+                                    'formdata' => collect($route['parameters'])->map(function($parameter, $key) {
47 47
                                         return [
48 48
                                             'key' => $key,
49 49
                                             'value' => isset($parameter['value']) ? $parameter['value'] : '',
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Generators/DingoGenerator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
         $routeDescription = $this->getRouteDescription($routeAction['uses']);
30 30
 
31 31
         return $this->getParameters([
32
-            'id' => md5($route->uri().':'.implode($route->getMethods())),
32
+            'id' => md5($route->uri() . ':' . implode($route->getMethods())),
33 33
             'resource' => $routeGroup,
34 34
             'title' => $routeDescription['short'],
35 35
             'description' => $routeDescription['long'],
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/ApiDocGeneratorServiceProvider.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
      */
16 16
     public function boot()
17 17
     {
18
-        $this->loadViewsFrom(__DIR__.'/../../resources/views/', 'apidoc');
19
-        $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'apidoc');
18
+        $this->loadViewsFrom(__DIR__ . '/../../resources/views/', 'apidoc');
19
+        $this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'apidoc');
20 20
 
21 21
         $this->publishes([
22
-            __DIR__.'/../../resources/lang' => $this->resource_path('lang/vendor/apidoc'),
23
-            __DIR__.'/../../resources/views' => $this->resource_path('views/vendor/apidoc'),
22
+            __DIR__ . '/../../resources/lang' => $this->resource_path('lang/vendor/apidoc'),
23
+            __DIR__ . '/../../resources/views' => $this->resource_path('views/vendor/apidoc'),
24 24
         ]);
25 25
     }
26 26
 
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function register()
33 33
     {
34
-        $this->app['apidoc.generate'] = $this->app->share(function () {
34
+        $this->app['apidoc.generate'] = $this->app->share(function() {
35 35
             return new GenerateDocumentation();
36 36
         });
37
-        $this->app['apidoc.update'] = $this->app->share(function () {
37
+        $this->app['apidoc.update'] = $this->app->share(function() {
38 38
             return new UpdateDocumentation();
39 39
         });
40 40
 
@@ -53,6 +53,6 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function resource_path($path = '')
55 55
     {
56
-        return app()->basePath().'/resources'.($path ? '/'.$path : $path);
56
+        return app()->basePath() . '/resources' . ($path ? '/' . $path : $path);
57 57
     }
58 58
 }
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Commands/GenerateDocumentation.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
         $this->setUserToBeImpersonated($this->option('actAsUserId'));
71 71
 
72
-        if ($routePrefix === null && ! count($allowedRoutes) && $middleware === null) {
72
+        if ($routePrefix === null && !count($allowedRoutes) && $middleware === null) {
73 73
             $this->error('You must provide either a route prefix or a route or a middleware to generate the documentation.');
74 74
 
75 75
             return false;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
     private function writeMarkdown($parsedRoutes)
94 94
     {
95 95
         $outputPath = $this->option('output');
96
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
97
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
96
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
97
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
98 98
 
99 99
         $infoText = view('apidoc::partials.info')
100 100
             ->with('outputPath', ltrim($outputPath, 'public/'))
101
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'));
101
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'));
102 102
 
103
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) {
104
-            return $routeGroup->map(function ($route) {
103
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) {
104
+            return $routeGroup->map(function($route) {
105 105
                 $route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route);
106 106
 
107 107
                 return $route;
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
125 125
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
126 126
             }
127 127
 
128
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
129
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
130
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) {
131
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]);
132
-                        if ($routeDocumentationChanged === false ||  $this->option('force')) {
128
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
129
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
130
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) {
131
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]);
132
+                        if ($routeDocumentationChanged === false || $this->option('force')) {
133 133
                             if ($routeDocumentationChanged) {
134
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
134
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
135 135
                             }
136 136
                         } else {
137
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
137
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
138 138
                             $route['modified_output'] = $routeMatch[0];
139 139
                         }
140 140
                     }
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
             ->with('frontmatter', $frontmatter)
152 152
             ->with('infoText', $infoText)
153 153
             ->with('outputPath', $this->option('output'))
154
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'))
154
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'))
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
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
             ->with('frontmatter', $frontmatter)
168 168
             ->with('infoText', $infoText)
169 169
             ->with('outputPath', $this->option('output'))
170
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'))
170
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'))
171 171
             ->with('parsedRoutes', $parsedRouteOutput);
172 172
 
173 173
         file_put_contents($compareFile, $compareMarkdown);
174 174
 
175
-        $this->info('Wrote index.md to: '.$outputPath);
175
+        $this->info('Wrote index.md to: ' . $outputPath);
176 176
 
177 177
         $this->info('Generating API HTML code');
178 178
 
179 179
         $documentarian->generate($outputPath);
180 180
 
181
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/public/index.html');
181
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/public/index.html');
182 182
 
183 183
 
184 184
         if ($this->option('noPostmanCollection') !== true) {
185 185
             $this->info('Generating Postman collection');
186 186
 
187
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
187
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
188 188
         }
189 189
     }
190 190
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     private function setUserToBeImpersonated($actAs)
214 214
     {
215
-        if (! empty($actAs)) {
215
+        if (!empty($actAs)) {
216 216
             if (version_compare($this->laravel->version(), '5.2.0', '<')) {
217 217
                 $userModel = config('auth.model');
218 218
                 $user = $userModel::find((int) $actAs);
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
             if (in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->getUri()) || in_array($middleware, $route->middleware())) {
255 255
                 if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
256 256
                     $parsedRoutes[] = $generator->processRoute($route, $bindings, $withResponse);
257
-                    $this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->getUri());
257
+                    $this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->getUri());
258 258
                 } else {
259
-                    $this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->getUri());
259
+                    $this->warn('Skipping route: [' . implode(',', $route->getMethods()) . '] ' . $route->getUri());
260 260
                 }
261 261
             }
262 262
         }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         foreach ($routes as $route) {
281 281
             if (empty($allowedRoutes) || in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->uri())) {
282 282
                 $parsedRoutes[] = $generator->processRoute($route, $bindings, $withResponse);
283
-                $this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->uri());
283
+                $this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri());
284 284
             }
285 285
         }
286 286
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      */
295 295
     private function isValidRoute($route)
296 296
     {
297
-        return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']);
297
+        return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']);
298 298
     }
299 299
 
300 300
     /**
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
             $phpdoc = new DocBlock($comment);
312 312
 
313 313
             return collect($phpdoc->getTags())
314
-                ->filter(function ($tag) use ($route) {
314
+                ->filter(function($tag) use ($route) {
315 315
                     return $tag->getName() === 'hideFromAPIDocumentation';
316 316
                 })
317 317
                 ->isEmpty();
Please login to merge, or discard this patch.