Completed
Pull Request — master (#318)
by
unknown
11:06
created

DingoGenerator::processRoute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
cc 3
nc 3
nop 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A DingoGenerator::callRoute() 0 10 1
A DingoGenerator::getDomain() 0 4 1
1
<?php
2
3
namespace Mpociot\ApiDoc\Generators;
4
5
6
class DingoGenerator extends AbstractGenerator
7
{
8
    /**
9
     * Prepares / Disables route middlewares.
10
     *
11
     * @param  bool $disable
12
     *
13
     * @return  void
14
     */
15
    public function prepareMiddleware($disable = true)
16
    {
17
        // Not needed by Dingo
18
        return false;
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function callRoute($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
25
    {
26
        $dispatcher = app('Dingo\Api\Dispatcher')->raw();
27
28
        collect($server)->map(function ($key, $value) use ($dispatcher) {
29
            $dispatcher->header($value, $key);
30
        });
31
32
        return call_user_func_array([$dispatcher, strtolower($method)], [$uri]);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getDomain($route)
39
    {
40
        return $route->domain();
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getUri($route)
47
    {
48
        return $route->uri();
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getMethods($route)
55
    {
56
        return array_diff($route->getMethods(), ['HEAD']);
57
    }
58
}
59