Completed
Push — 8.x-1.x ( 4cc04a...006414 )
by
unknown
27:53
created

Route::modifyRouteMethod()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 3
crap 2
1
<?php
2
3
namespace Drupal\controller_annotations\Configuration;
4
5
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route as BaseRoute;
6
use Symfony\Component\Routing\Route as RoutingRoute;
7
8
/**
9
 * @Annotation
10
 */
11
class Route extends BaseRoute implements RouteModifierMethodInterface, RouteModifierClassInterface
12
{
13
    /**
14
     * @var bool
15
     */
16
    protected $admin;
17
18
    /**
19
     * @return bool
20
     */
21 8
    public function isAdmin()
22
    {
23 8
        return $this->admin;
24
    }
25
26
    /**
27
     * @param bool $admin
28
     * @return Route
29
     */
30 7
    public function setAdmin($admin)
31
    {
32 7
        $this->admin = $admin;
33
34 7
        return $this;
35
    }
36
37
    /**
38
     * @param RoutingRoute $route
39
     * @param \ReflectionClass $class
40
     * @param \ReflectionMethod $method
41
     */
42 7
    public function modifyRouteClass(RoutingRoute $route, \ReflectionClass $class, \ReflectionMethod $method)
43
    {
44 7
        $this->modifyRoute($route, $class, $method);
45 7
    }
46
47
    /**
48
     * @param RoutingRoute $route
49
     * @param \ReflectionClass $class
50
     * @param \ReflectionMethod $method
51
     */
52 8
    public function modifyRouteMethod(RoutingRoute $route, \ReflectionClass $class, \ReflectionMethod $method)
53
    {
54 8
        if ($this->getService()) {
55 1
            throw new \LogicException('The service option can only be specified at class level.');
56
        }
57
58 7
        $this->modifyRoute($route, $class, $method);
59 7
    }
60
61
    /**
62
     * @param RoutingRoute $route
63
     * @param \ReflectionClass $class
64
     * @param \ReflectionMethod $method
65
     */
66 8
    protected function modifyRoute(RoutingRoute $route, \ReflectionClass $class, \ReflectionMethod $method)
0 ignored issues
show
Unused Code introduced by
The parameter $class 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...
Unused Code introduced by
The parameter $method 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...
67
    {
68 8
        if ($this->isAdmin()) {
69 7
            $route->setOption('_admin_route', true);
70
        }
71 8
    }
72
}
73