Passed
Pull Request — master (#11)
by Tom
02:15
created

RestfulResourceRegistrar::addResourceOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
namespace TomHart\Restful\Routing;
4
5
use Illuminate\Routing\ResourceRegistrar;
6
use Illuminate\Routing\Route;
7
use Illuminate\Routing\Router;
8
9
class RestfulResourceRegistrar extends ResourceRegistrar
10
{
11
12
13
    public function __construct(Router $router)
14
    {
15
        parent::__construct($router);
16
17
        $this->resourceDefaults[] = 'showExtra';
18
        $this->resourceDefaults[] = 'options';
19
    }
20
21
    /**
22
     * Add the show-extra method for a resourceful route.
23
     *
24
     * @param string $name
25
     * @param string $base
26
     * @param string $controller
27
     * @param mixed[] $options
28
     * @return Route
29
     */
30
    protected function addResourceShowExtra($name, $base, $controller, $options)
31
    {
32
        $uri = $this->getResourceUri($name) . '/{' . $base . '}/{extra}';
33
34
        $action = $this->getResourceAction($name, $controller, 'show', $options);
35
36
        $action['as'] .= '.extra';
37
38
        return $this->router->get($uri, $action)->where('extra', '.*');
39
    }
40
41
    /**
42
     * Add the options method for a resourceful route.
43
     *
44
     * @param string $name
45
     * @param string $base
46
     * @param string $controller
47
     * @param mixed[] $options
48
     * @return Route
49
     */
50
    protected function addResourceOptions($name, $base, $controller, $options)
0 ignored issues
show
Unused Code introduced by
The parameter $base is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
    {
52
        $uri = $this->getResourceUri($name);
53
54
        $action = $this->getResourceAction($name, $controller, 'options', $options);
55
56
        return $this->router->options($uri, $action);
57
    }
58
}
59