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

DingoGenerator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 53
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareMiddleware() 0 5 1
A callRoute() 0 10 1
A getDomain() 0 4 1
A getUri() 0 4 1
A getMethods() 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