Completed
Push — master ( d37e1c...8b72ea )
by Marcel
03:00
created

DingoGenerator::processRoute()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 3
Metric Value
c 4
b 1
f 3
dl 0
loc 24
rs 8.9713
cc 3
eloc 18
nc 3
nop 3
1
<?php
2
3
namespace Mpociot\ApiDoc\Generators;
4
5
use Exception;
6
7
class DingoGenerator extends AbstractGenerator
8
{
9
    /**
10
     * @param \Illuminate\Routing\Route $route
11
     * @param array $bindings
12
     * @param bool $withResponse
13
     * 
14
     * @return array
15
     */
16
    public function processRoute($route, $bindings = [], $withResponse = true)
17
    {
18
        $response = '';
19
        
20
        if ($withResponse) {
21
            try {
22
                $response = $this->getRouteResponse($route, $bindings);
23
            } catch (Exception $e) {}
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
24
        }
25
        
26
        $routeAction = $route->getAction();
27
        $routeGroup = $this->getRouteGroup($routeAction['uses']);
28
        $routeDescription = $this->getRouteDescription($routeAction['uses']);
29
30
        return $this->getParameters([
31
            'resource' => $routeGroup,
32
            'title' => $routeDescription['short'],
33
            'description' => $routeDescription['long'],
34
            'methods' => $route->getMethods(),
35
            'uri' => $route->uri(),
36
            'parameters' => [],
37
            'response' => $response,
38
        ], $routeAction);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function callRoute($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
45
    {
46
        return call_user_func_array([app('Dingo\Api\Dispatcher'), strtolower($method)], [$uri]);
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    protected function getUri($route)
53
    {
54
        return $route->uri();
55
    }
56
}
57