Completed
Push — master ( 12abac...a4ad23 )
by Marcel
05:10
created
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->singleton('apidoc.generate', function () {
34
+        $this->app->singleton('apidoc.generate', function() {
35 35
             return new GenerateDocumentation();
36 36
         });
37
-        $this->app->singleton('apidoc.update', function () {
37
+        $this->app->singleton('apidoc.update', 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/Generators/LaravelGenerator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         }
63 63
 
64 64
         return $this->getParameters([
65
-            'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
65
+            'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))),
66 66
             'resource' => $routeGroup,
67 67
             'title' => $routeDescription['short'],
68 68
             'description' => $routeDescription['long'],
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
         $kernel->terminate($request, $response);
117 117
 
118
-        if (file_exists($file = App::bootstrapPath().'/app.php')) {
118
+        if (file_exists($file = App::bootstrapPath() . '/app.php')) {
119 119
             $app = require $file;
120 120
             $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
121 121
         }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 
138 138
         foreach ($reflectionMethod->getParameters() as $parameter) {
139 139
             $parameterType = $parameter->getClass();
140
-            if (! is_null($parameterType) && class_exists($parameterType->name)) {
140
+            if (!is_null($parameterType) && class_exists($parameterType->name)) {
141 141
                 $className = $parameterType->name;
142 142
 
143 143
                 if (is_subclass_of($className, FormRequest::class)) {
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Commands/GenerateDocumentation.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
         $this->setUserToBeImpersonated($this->option('actAsUserId'));
73 73
 
74
-        if ($routePrefix === null && ! count($allowedRoutes) && $middleware === null) {
74
+        if ($routePrefix === null && !count($allowedRoutes) && $middleware === null) {
75 75
             $this->error('You must provide either a route prefix or a route or a middleware to generate the documentation.');
76 76
 
77 77
             return false;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         } else {
85 85
             $parsedRoutes = $this->processDingoRoutes($generator, $allowedRoutes, $routePrefix, $middleware);
86 86
         }
87
-        $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function ($a, $b) {
87
+        $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function($a, $b) {
88 88
             return strcmp($a->first()['resource'], $b->first()['resource']);
89 89
         });
90 90
 
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
     private function writeMarkdown($parsedRoutes)
100 100
     {
101 101
         $outputPath = $this->option('output');
102
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
103
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
102
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
103
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
104 104
 
105 105
         $infoText = view('apidoc::partials.info')
106 106
             ->with('outputPath', ltrim($outputPath, 'public/'))
107
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'));
107
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'));
108 108
 
109
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) {
110
-            return $routeGroup->map(function ($route) {
109
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) {
110
+            return $routeGroup->map(function($route) {
111 111
                 $route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route);
112 112
 
113 113
                 return $route;
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
132 132
             }
133 133
 
134
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
135
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
136
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) {
137
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]);
134
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
135
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
136
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) {
137
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]);
138 138
                         if ($routeDocumentationChanged === false || $this->option('force')) {
139 139
                             if ($routeDocumentationChanged) {
140
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
140
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
141 141
                             }
142 142
                         } else {
143
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
143
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
144 144
                             $route['modified_output'] = $routeMatch[0];
145 145
                         }
146 146
                     }
@@ -157,10 +157,10 @@  discard block
 block discarded – undo
157 157
             ->with('frontmatter', $frontmatter)
158 158
             ->with('infoText', $infoText)
159 159
             ->with('outputPath', $this->option('output'))
160
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'))
160
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'))
161 161
             ->with('parsedRoutes', $parsedRouteOutput);
162 162
 
163
-        if (! is_dir($outputPath)) {
163
+        if (!is_dir($outputPath)) {
164 164
             $documentarian->create($outputPath);
165 165
         }
166 166
 
@@ -173,23 +173,23 @@  discard block
 block discarded – undo
173 173
             ->with('frontmatter', $frontmatter)
174 174
             ->with('infoText', $infoText)
175 175
             ->with('outputPath', $this->option('output'))
176
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'))
176
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'))
177 177
             ->with('parsedRoutes', $parsedRouteOutput);
178 178
 
179 179
         file_put_contents($compareFile, $compareMarkdown);
180 180
 
181
-        $this->info('Wrote index.md to: '.$outputPath);
181
+        $this->info('Wrote index.md to: ' . $outputPath);
182 182
 
183 183
         $this->info('Generating API HTML code');
184 184
 
185 185
         $documentarian->generate($outputPath);
186 186
 
187
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/public/index.html');
187
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/public/index.html');
188 188
 
189 189
         if ($this->option('noPostmanCollection') !== true) {
190 190
             $this->info('Generating Postman collection');
191 191
 
192
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
192
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
193 193
         }
194 194
     }
195 195
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      */
218 218
     private function setUserToBeImpersonated($actAs)
219 219
     {
220
-        if (! empty($actAs)) {
220
+        if (!empty($actAs)) {
221 221
             if (version_compare($this->laravel->version(), '5.2.0', '<')) {
222 222
                 $userModel = config('auth.model');
223 223
                 $user = $userModel::find((int) $actAs);
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
             if (in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $generator->getUri($route)) || in_array($middleware, $route->middleware())) {
260 260
                 if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
261 261
                     $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse);
262
-                    $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
262
+                    $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
263 263
                 } else {
264
-                    $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
264
+                    $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
265 265
                 }
266 266
             }
267 267
         }
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
             if (empty($allowedRoutes) || in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->uri()) || in_array($middleware, $route->middleware())) {
287 287
                 if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
288 288
                     $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse);
289
-                    $this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->uri());
289
+                    $this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri());
290 290
                 } else {
291
-                    $this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->uri());
291
+                    $this->warn('Skipping route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri());
292 292
                 }
293 293
             }
294 294
         }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      */
304 304
     private function isValidRoute($route)
305 305
     {
306
-        return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']);
306
+        return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']);
307 307
     }
308 308
 
309 309
     /**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
             $phpdoc = new DocBlock($comment);
321 321
 
322 322
             return collect($phpdoc->getTags())
323
-                ->filter(function ($tag) use ($route) {
323
+                ->filter(function($tag) use ($route) {
324 324
                     return $tag->getName() === 'hideFromAPIDocumentation';
325 325
                 })
326 326
                 ->isEmpty();
Please login to merge, or discard this patch.