Completed
Pull Request — master (#681)
by
unknown
13:51
created
src/Writing/Writer.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function writeMarkdownAndSourceFiles(Collection $parsedRoutes)
93 93
     {
94
-        $targetFile = $this->sourceOutputPath.'/source/index.md';
95
-        $compareFile = $this->sourceOutputPath.'/source/.compare.md';
94
+        $targetFile = $this->sourceOutputPath . '/source/index.md';
95
+        $compareFile = $this->sourceOutputPath . '/source/.compare.md';
96 96
 
97 97
         $infoText = view($this->config->get('info_view', 'apidoc::partials.info'))
98 98
             ->with('outputPath', 'docs')
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
             $generatedDocumentation = file_get_contents($targetFile);
115 115
             $compareDocumentation = file_get_contents($compareFile);
116 116
 
117
-            $parsedRouteOutput->transform(function (Collection $routeGroup) use ($generatedDocumentation, $compareDocumentation) {
118
-                return $routeGroup->transform(function (array $route) use ($generatedDocumentation, $compareDocumentation) {
119
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) {
120
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
117
+            $parsedRouteOutput->transform(function(Collection $routeGroup) use ($generatedDocumentation, $compareDocumentation) {
118
+                return $routeGroup->transform(function(array $route) use ($generatedDocumentation, $compareDocumentation) {
119
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) {
120
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
121 121
                         if ($routeDocumentationChanged === false || $this->forceIt) {
122 122
                             if ($routeDocumentationChanged) {
123
-                                $this->output->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
123
+                                $this->output->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
124 124
                             }
125 125
                         } else {
126
-                            $this->output->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
126
+                            $this->output->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
127 127
                             $route['modified_output'] = $existingRouteDoc[0];
128 128
                         }
129 129
                     }
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection)
147 147
             ->with('parsedRoutes', $parsedRouteOutput);
148 148
 
149
-        $this->output->info('Writing index.md and source files to: '.$this->sourceOutputPath);
149
+        $this->output->info('Writing index.md and source files to: ' . $this->sourceOutputPath);
150 150
 
151
-        if (! is_dir($this->sourceOutputPath)) {
151
+        if (!is_dir($this->sourceOutputPath)) {
152 152
             $documentarian = new Documentarian();
153 153
             $documentarian->create($this->sourceOutputPath);
154 154
         }
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
 
170 170
         file_put_contents($compareFile, $compareMarkdown);
171 171
 
172
-        $this->output->info('Wrote index.md and source files to: '.$this->sourceOutputPath);
172
+        $this->output->info('Wrote index.md and source files to: ' . $this->sourceOutputPath);
173 173
     }
174 174
 
175 175
     public function generateMarkdownOutputForEachRoute(Collection $parsedRoutes, array $settings): Collection
176 176
     {
177
-        $parsedRouteOutput = $parsedRoutes->map(function (Collection $routeGroup) use ($settings) {
178
-            return $routeGroup->map(function (array $route) use ($settings) {
179
-                if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) {
177
+        $parsedRouteOutput = $parsedRoutes->map(function(Collection $routeGroup) use ($settings) {
178
+            return $routeGroup->map(function(array $route) use ($settings) {
179
+                if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) {
180 180
                     // Set content type if the user forgot to set it
181 181
                     $route['headers']['Content-Type'] = 'application/json';
182 182
                 }
183 183
 
184
-                $hasRequestOptions = ! empty($route['headers']) || ! empty($route['cleanQueryParameters']) || ! empty($route['cleanBodyParameters']);
184
+                $hasRequestOptions = !empty($route['headers']) || !empty($route['cleanQueryParameters']) || !empty($route['cleanBodyParameters']);
185 185
                 $route['output'] = (string) view('apidoc::partials.route')
186 186
                     ->with('hasRequestOptions', $hasRequestOptions)
187 187
                     ->with('route', $route)
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
 
235 235
     protected function getMarkdownToPrepend(): string
236 236
     {
237
-        $prependFile = $this->sourceOutputPath.'/source/prepend.md';
237
+        $prependFile = $this->sourceOutputPath . '/source/prepend.md';
238 238
         $prependFileContents = file_exists($prependFile)
239
-            ? file_get_contents($prependFile)."\n" : '';
239
+            ? file_get_contents($prependFile) . "\n" : '';
240 240
 
241 241
         return $prependFileContents;
242 242
     }
243 243
 
244 244
     protected function getMarkdownToAppend(): string
245 245
     {
246
-        $appendFile = $this->sourceOutputPath.'/source/append.md';
246
+        $appendFile = $this->sourceOutputPath . '/source/append.md';
247 247
         $appendFileContents = file_exists($appendFile)
248
-            ? "\n".file_get_contents($appendFile) : '';
248
+            ? "\n" . file_get_contents($appendFile) : '';
249 249
 
250 250
         return $appendFileContents;
251 251
     }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     protected function copyAssetsFromSourceFolderToPublicFolder(): void
254 254
     {
255 255
         $publicPath = 'public/docs';
256
-        if (! is_dir($publicPath)) {
256
+        if (!is_dir($publicPath)) {
257 257
             mkdir($publicPath, 0777, true);
258 258
             mkdir("{$publicPath}/css");
259 259
             mkdir("{$publicPath}/js");
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
             rename("{$this->sourceOutputPath}/index.html", "{$this->outputPath}/index.html");
275 275
         } else {
276 276
             // Move output to resources/views
277
-            if (! is_dir($this->outputPath)) {
277
+            if (!is_dir($this->outputPath)) {
278 278
                 mkdir($this->outputPath);
279 279
             }
280 280
             rename("{$this->sourceOutputPath}/index.html", "$this->outputPath/index.blade.php");
Please login to merge, or discard this patch.