Completed
Pull Request — master (#334)
by
unknown
02:48
created
src/Mpociot/ApiDoc/Generators/AbstractGenerator.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             $response = $docblockResponse;
76 76
             $showresponse = true;
77 77
         }
78
-        if (! $response) {
78
+        if (!$response) {
79 79
             $transformerResponse = $this->getTransformerResponse($routeDescription['tags']);
80 80
             if ($transformerResponse) {
81 81
                 // we have a transformer response from the docblock ( @transformer || @transformercollection )
@@ -83,20 +83,20 @@  discard block
 block discarded – undo
83 83
                 $showresponse = true;
84 84
             }
85 85
         }
86
-        if (! $response && $withResponse) {
86
+        if (!$response && $withResponse) {
87 87
             try {
88 88
                 // we have a queryParameters array from the docblock
89 89
                 $parameters = $this->getQueryParameters($routeDescription['tags']);
90 90
                 $response = $this->getRouteResponse($route, $bindings, $parameters, $headers);
91 91
             } catch (\Exception $e) {
92
-                echo "Couldn't get response for route: ".implode(',', $this->getMethods($route)).$route->uri().']: '.$e->getMessage()."\n";
92
+                echo "Couldn't get response for route: " . implode(',', $this->getMethods($route)) . $route->uri() . ']: ' . $e->getMessage() . "\n";
93 93
             }
94 94
         }
95 95
 
96 96
         $content = $this->getResponseContent($response);
97 97
 
98 98
         return $this->getParameters([
99
-            'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
99
+            'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))),
100 100
             'resource' => $routeGroup,
101 101
             'title' => $routeDescription['short'],
102 102
             'description' => $routeDescription['long'],
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
      */
127 127
     protected function getDocblockResponse($tags)
128 128
     {
129
-        $responseTags = array_filter($tags, function ($tag) {
130
-            if (! ($tag instanceof Tag)) {
129
+        $responseTags = array_filter($tags, function($tag) {
130
+            if (!($tag instanceof Tag)) {
131 131
                 return false;
132 132
             }
133 133
 
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
         // Laravel will ignore the nested array rules unless the key referenced exists and is an array
190 190
         // So we'll to create an empty array for each array attribute
191 191
         $values = collect($rules)
192
-            ->filter(function ($values) {
192
+            ->filter(function($values) {
193 193
                 return in_array('array', $values);
194
-            })->map(function ($val, $key) {
194
+            })->map(function($val, $key) {
195 195
                 return [''];
196 196
             })->all();
197 197
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $methods = $this->getMethods($route);
215 215
 
216 216
         // Split headers into key - value pairs
217
-        $headers = collect($headers)->map(function ($value) {
217
+        $headers = collect($headers)->map(function($value) {
218 218
             $split = explode(':', $value); // explode to get key + values
219 219
             $key = array_shift($split); // extract the key and keep the values in the array
220 220
             $value = implode(':', $split); // implode values into string again
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
      */
238 238
     protected function getQueryParameters($tags)
239 239
     {
240
-        $responseTags = array_filter($tags, function ($tag) {
241
-            if (! ($tag instanceof Tag)) {
240
+        $responseTags = array_filter($tags, function($tag) {
241
+            if (!($tag instanceof Tag)) {
242 242
                 return false;
243 243
             }
244 244
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 
254 254
         $parameters = \json_decode($responseTag->getContent(), true);
255 255
         
256
-        if(! is_array($parameters)) {
256
+        if (!is_array($parameters)) {
257 257
             $parameters = [];
258 258
         }
259 259
         
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
     {
271 271
         $uri = $this->getUri($route);
272 272
         foreach ($bindings as $model => $id) {
273
-            $uri = str_replace('{'.$model.'}', $id, $uri);
274
-            $uri = str_replace('{'.$model.'?}', $id, $uri);
273
+            $uri = str_replace('{' . $model . '}', $id, $uri);
274
+            $uri = str_replace('{' . $model . '?}', $id, $uri);
275 275
         }
276 276
 
277 277
         return $uri;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 
336 336
         foreach ($reflectionMethod->getParameters() as $parameter) {
337 337
             $parameterType = $parameter->getClass();
338
-            if (! is_null($parameterType) && class_exists($parameterType->name)) {
338
+            if (!is_null($parameterType) && class_exists($parameterType->name)) {
339 339
                 $className = $parameterType->name;
340 340
 
341 341
                 if (is_subclass_of($className, FormRequest::class)) {
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
      */
372 372
     protected function fancyImplode($arr, $first, $last)
373 373
     {
374
-        $arr = array_map(function ($value) {
375
-            return '`'.$value.'`';
374
+        $arr = array_map(function($value) {
375
+            return '`' . $value . '`';
376 376
         }, $arr);
377 377
         array_push($arr, implode($last, array_splice($arr, -2)));
378 378
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
     protected function splitValuePairs($parameters, $first = 'is ', $last = 'or ')
383 383
     {
384 384
         $attribute = '';
385
-        collect($parameters)->map(function ($item, $key) use (&$attribute, $first, $last) {
386
-            $attribute .= '`'.$item.'` ';
385
+        collect($parameters)->map(function($item, $key) use (&$attribute, $first, $last) {
386
+            $attribute .= '`' . $item . '` ';
387 387
             if (($key + 1) % 2 === 0) {
388 388
                 $attribute .= $last;
389 389
             } else {
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
                 }
467 467
                 break;
468 468
             case 'between':
469
-                if (! isset($attributeData['type'])) {
469
+                if (!isset($attributeData['type'])) {
470 470
                     $attributeData['type'] = 'numeric';
471 471
                 }
472 472
                 $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
         foreach ($headers as $name => $value) {
645 645
             $name = strtr(strtoupper($name), '-', '_');
646 646
 
647
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
648
-                $name = $prefix.$name;
647
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
648
+                $name = $prefix . $name;
649 649
             }
650 650
 
651 651
             $server[$name] = $value;
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
     protected function getTransformerResponse($tags)
743 743
     {
744 744
         try {
745
-            $transFormerTags = array_filter($tags, function ($tag) {
746
-                if (! ($tag instanceof Tag)) {
745
+            $transFormerTags = array_filter($tags, function($tag) {
746
+                if (!($tag instanceof Tag)) {
747 747
                     return false;
748 748
                 }
749 749
 
@@ -754,8 +754,8 @@  discard block
 block discarded – undo
754 754
                 return false;
755 755
             }
756 756
 
757
-            $modelTag = array_first(array_filter($tags, function ($tag) {
758
-                if (! ($tag instanceof Tag)) {
757
+            $modelTag = array_first(array_filter($tags, function($tag) {
758
+                if (!($tag instanceof Tag)) {
759 759
                     return false;
760 760
                 }
761 761
 
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
             }));
764 764
             $tag = \array_first($transFormerTags);
765 765
             $transformer = $tag->getContent();
766
-            if (! \class_exists($transformer)) {
766
+            if (!\class_exists($transformer)) {
767 767
                 // if we can't find the transformer we can't generate a response
768 768
                 return;
769 769
             }
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
             if (version_compare(PHP_VERSION, '7.0.0') >= 0 && \is_null($type)) {
780 780
                 // we can only get the type with reflection for PHP 7
781 781
                 if ($parameter->hasType() &&
782
-                    ! $parameter->getType()->isBuiltin() &&
782
+                    !$parameter->getType()->isBuiltin() &&
783 783
                     \class_exists((string) $parameter->getType())) {
784 784
                     //we have a type
785 785
                     $type = (string) $parameter->getType();
Please login to merge, or discard this patch.