Completed
Push — master ( 15a84d...ee0f50 )
by
unknown
11s
created
src/Generators/AbstractGenerator.php 2 patches
Doc Comments   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * @param Route $route
29 29
      *
30
-     * @return mixed
30
+     * @return string
31 31
      */
32 32
     public function getUri(Route $route)
33 33
     {
@@ -46,7 +46,6 @@  discard block
 block discarded – undo
46 46
 
47 47
     /**
48 48
      * @param  \Illuminate\Routing\Route $route
49
-     * @param array $apply Rules to apply when generating documentation for this route
50 49
      *
51 50
      * @return array
52 51
      */
@@ -73,7 +72,6 @@  discard block
 block discarded – undo
73 72
     /**
74 73
      * Prepares / Disables route middlewares.
75 74
      *
76
-     * @param  bool $disable
77 75
      *
78 76
      * @return  void
79 77
      */
@@ -168,7 +166,7 @@  discard block
 block discarded – undo
168 166
      * @param $route
169 167
      * @param array $bindings
170 168
      *
171
-     * @return mixed
169
+     * @return string
172 170
      */
173 171
     protected function addRouteModelBindings($route, $bindings)
174 172
     {
@@ -184,7 +182,7 @@  discard block
 block discarded – undo
184 182
     /**
185 183
      * @param  \Illuminate\Routing\Route  $route
186 184
      *
187
-     * @return array
185
+     * @return Route
188 186
      */
189 187
     protected function parseDocBlock($route)
190 188
     {
@@ -392,6 +390,9 @@  discard block
 block discarded – undo
392 390
         return $content;
393 391
     }
394 392
 
393
+    /**
394
+     * @return string
395
+     */
395 396
     private function normalizeParameterType($type)
396 397
     {
397 398
         $typeMap = [
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $content = $this->getResponse($docBlock['tags']);
59 59
 
60 60
         return [
61
-            'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
61
+            'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))),
62 62
             'resource' => $routeGroup,
63 63
             'title' => $docBlock['short'],
64 64
             'description' => $docBlock['long'],
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             'uri' => $this->getUri($route),
67 67
             'parameters' => $this->getParametersFromDocBlock($docBlock['tags']),
68 68
             'response' => $content,
69
-            'showresponse' => ! empty($content),
69
+            'showresponse' => !empty($content),
70 70
         ];
71 71
     }
72 72
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     protected function getDocblockResponse($tags)
90 90
     {
91
-        $responseTags = array_filter($tags, function ($tag) {
91
+        $responseTags = array_filter($tags, function($tag) {
92 92
             return $tag instanceof Tag && \strtolower($tag->getName()) == 'response';
93 93
         });
94 94
         if (empty($responseTags)) {
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
     protected function getParametersFromDocBlock($tags)
108 108
     {
109 109
         $parameters = collect($tags)
110
-            ->filter(function ($tag) {
110
+            ->filter(function($tag) {
111 111
                 return $tag instanceof Tag && $tag->getName() === 'bodyParam';
112 112
             })
113
-            ->mapWithKeys(function ($tag) {
113
+            ->mapWithKeys(function($tag) {
114 114
                 preg_match('/(.+?)\s+(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content);
115 115
                 if (empty($content)) {
116 116
                     // this means only name and type were supplied
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         $methods = $this->getMethods($route);
151 151
 
152 152
         // Split headers into key - value pairs
153
-        $headers = collect($headers)->map(function ($value) {
153
+        $headers = collect($headers)->map(function($value) {
154 154
             $split = explode(':', $value); // explode to get key + values
155 155
             $key = array_shift($split); // extract the key and keep the values in the array
156 156
             $value = implode(':', $split); // implode values into string again
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
     {
175 175
         $uri = $this->getUri($route);
176 176
         foreach ($bindings as $model => $id) {
177
-            $uri = str_replace('{'.$model.'}', $id, $uri);
178
-            $uri = str_replace('{'.$model.'?}', $id, $uri);
177
+            $uri = str_replace('{' . $model . '}', $id, $uri);
178
+            $uri = str_replace('{' . $model . '?}', $id, $uri);
179 179
         }
180 180
 
181 181
         return $uri;
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
         foreach ($headers as $name => $value) {
255 255
             $name = strtr(strtoupper($name), '-', '_');
256 256
 
257
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
258
-                $name = $prefix.$name;
257
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
258
+                $name = $prefix . $name;
259 259
             }
260 260
 
261 261
             $server[$name] = $value;
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
     protected function getTransformerResponse($tags)
294 294
     {
295 295
         try {
296
-            $transFormerTags = array_filter($tags, function ($tag) {
297
-                if (! ($tag instanceof Tag)) {
296
+            $transFormerTags = array_filter($tags, function($tag) {
297
+                if (!($tag instanceof Tag)) {
298 298
                     return false;
299 299
                 }
300 300
 
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
                 return false;
306 306
             }
307 307
 
308
-            $modelTag = array_first(array_filter($tags, function ($tag) {
309
-                if (! ($tag instanceof Tag)) {
308
+            $modelTag = array_first(array_filter($tags, function($tag) {
309
+                if (!($tag instanceof Tag)) {
310 310
                     return false;
311 311
                 }
312 312
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             }));
315 315
             $tag = \array_first($transFormerTags);
316 316
             $transformer = $tag->getContent();
317
-            if (! \class_exists($transformer)) {
317
+            if (!\class_exists($transformer)) {
318 318
                 // if we can't find the transformer we can't generate a response
319 319
                 return;
320 320
             }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             }
330 330
             if (\is_null($type)) {
331 331
                 if ($parameter->hasType() &&
332
-                    ! $parameter->getType()->isBuiltin() &&
332
+                    !$parameter->getType()->isBuiltin() &&
333 333
                     \class_exists((string) $parameter->getType())) {
334 334
                     //we have a type
335 335
                     $type = (string) $parameter->getType();
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
             // we have a response from the docblock ( @response )
383 383
             $response = $docblockResponse;
384 384
         }
385
-        if (! $response && ($transformerResponse = $this->getTransformerResponse($annotationTags))) {
385
+        if (!$response && ($transformerResponse = $this->getTransformerResponse($annotationTags))) {
386 386
             // we have a transformer response from the docblock ( @transformer || @transformercollection )
387 387
             $response = $transformerResponse;
388 388
         }
@@ -407,25 +407,25 @@  discard block
 block discarded – undo
407 407
     {
408 408
         $faker = Factory::create();
409 409
         $fakes = [
410
-            'integer' => function () {
410
+            'integer' => function() {
411 411
                 return rand(1, 20);
412 412
             },
413
-            'number' => function () use ($faker) {
413
+            'number' => function() use ($faker) {
414 414
                 return $faker->randomFloat();
415 415
             },
416
-            'float' => function () use ($faker) {
416
+            'float' => function() use ($faker) {
417 417
                 return $faker->randomFloat();
418 418
             },
419
-            'boolean' => function () use ($faker) {
419
+            'boolean' => function() use ($faker) {
420 420
                 return $faker->boolean();
421 421
             },
422
-            'string' => function () use ($faker) {
422
+            'string' => function() use ($faker) {
423 423
                 return str_random();
424 424
             },
425
-            'array' => function () {
425
+            'array' => function() {
426 426
                 return '[]';
427 427
             },
428
-            'object' => function () {
428
+            'object' => function() {
429 429
                 return '{}';
430 430
             },
431 431
         ];
Please login to merge, or discard this patch.