Completed
Push — master ( 02d194...503fb6 )
by Marcel
03:10 queued 01:35
created
src/Commands/GenerateDocumentation.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $generator = new Generator();
57 57
         $parsedRoutes = $this->processRoutes($generator, $routes);
58 58
         $parsedRoutes = collect($parsedRoutes)->groupBy('group')
59
-            ->sortBy(static function ($group) {
59
+            ->sortBy(static function($group) {
60 60
                 /* @var $group Collection */
61 61
                 return $group->first()['group'];
62 62
             }, SORT_NATURAL);
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
     private function writeMarkdown($parsedRoutes)
73 73
     {
74 74
         $outputPath = config('apidoc.output');
75
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
76
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
77
-        $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md';
78
-        $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md';
75
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
76
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
77
+        $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md';
78
+        $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md';
79 79
 
80 80
         $infoText = view('apidoc::partials.info')
81 81
             ->with('outputPath', ltrim($outputPath, 'public/'))
82 82
             ->with('showPostmanCollectionButton', config('apidoc.postman'));
83 83
 
84
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) {
85
-            return $routeGroup->map(function ($route) {
84
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) {
85
+            return $routeGroup->map(function($route) {
86 86
                 $route['output'] = (string) view('apidoc::partials.route')->with('route', $route)->render();
87 87
 
88 88
                 return $route;
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
103 103
             }
104 104
 
105
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
106
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
107
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) {
108
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
105
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
106
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
107
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) {
108
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
109 109
                         if ($routeDocumentationChanged === false || $this->option('force')) {
110 110
                             if ($routeDocumentationChanged) {
111
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
111
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
112 112
                             }
113 113
                         } else {
114
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
114
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
115 115
                             $route['modified_output'] = $existingRouteDoc[0];
116 116
                         }
117 117
                     }
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
         }
123 123
 
124 124
         $prependFileContents = file_exists($prependFile)
125
-            ? file_get_contents($prependFile)."\n" : '';
125
+            ? file_get_contents($prependFile) . "\n" : '';
126 126
         $appendFileContents = file_exists($appendFile)
127
-            ? "\n".file_get_contents($appendFile) : '';
127
+            ? "\n" . file_get_contents($appendFile) : '';
128 128
 
129 129
         $documentarian = new Documentarian();
130 130
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             ->with('showPostmanCollectionButton', config('apidoc.postman'))
139 139
             ->with('parsedRoutes', $parsedRouteOutput);
140 140
 
141
-        if (! is_dir($outputPath)) {
141
+        if (!is_dir($outputPath)) {
142 142
             $documentarian->create($outputPath);
143 143
         }
144 144
 
@@ -158,24 +158,24 @@  discard block
 block discarded – undo
158 158
 
159 159
         file_put_contents($compareFile, $compareMarkdown);
160 160
 
161
-        $this->info('Wrote index.md to: '.$outputPath);
161
+        $this->info('Wrote index.md to: ' . $outputPath);
162 162
 
163 163
         $this->info('Generating API HTML code');
164 164
 
165 165
         $documentarian->generate($outputPath);
166 166
 
167
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
167
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
168 168
 
169 169
         if (config('apidoc.postman')) {
170 170
             $this->info('Generating Postman collection');
171 171
 
172
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
172
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
173 173
         }
174 174
 
175 175
         if ($logo = config('apidoc.logo')) {
176 176
             copy(
177 177
                 $logo,
178
-                $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png'
178
+                $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png'
179 179
             );
180 180
         }
181 181
     }
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
             /** @var Route $route */
195 195
             if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
196 196
                 $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']);
197
-                $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
197
+                $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
198 198
             } else {
199
-                $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
199
+                $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
200 200
             }
201 201
         }
202 202
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     private function isValidRoute(Route $route)
212 212
     {
213
-        return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']);
213
+        return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']);
214 214
     }
215 215
 
216 216
     /**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         list($class, $method) = explode('@', $route);
226 226
         $reflection = new ReflectionClass($class);
227 227
 
228
-        if (! $reflection->hasMethod($method)) {
228
+        if (!$reflection->hasMethod($method)) {
229 229
             return false;
230 230
         }
231 231
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
             $phpdoc = new DocBlock($comment);
236 236
 
237 237
             return collect($phpdoc->getTags())
238
-                ->filter(function ($tag) use ($route) {
238
+                ->filter(function($tag) use ($route) {
239 239
                     return $tag->getName() === 'hideFromAPIDocumentation';
240 240
                 })
241 241
                 ->isEmpty();
Please login to merge, or discard this patch.