Passed
Push — develop ( 355f63...51016a )
by Mathieu
02:23
created

AddRoute   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
dl 0
loc 37
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Neimheadh\SonataAnnotationBundle\Annotation\Sonata;
6
7
use Attribute;
8
use Neimheadh\SonataAnnotationBundle\Annotation\AbstractAnnotation;
9
use Neimheadh\SonataAnnotationBundle\Annotation\RouteAnnotationInterface;
10
use ReflectionException;
11
12
/**
13
 * Add route annotation.
14
 *
15
 * Add custom route to your admin class.
16
 *
17
 * @Annotation
18
 * @Target("CLASS")
19
 *
20
 * @author Marko Kunic <[email protected]>
21
 * @author Mathieu Wambre <[email protected]>
22
 */
23
#[Attribute(Attribute::TARGET_CLASS)]
24
final class AddRoute extends AbstractAnnotation implements
25
    RouteAnnotationInterface
26
{
27
28
    public const ID_PARAMETER = '{id}';
29
30
    /**
31
     * Route name.
32
     *
33
     * @var string|null
34
     */
35
    public ?string $name = null;
36
37
    /**
38
     * Route path.
39
     *
40
     * @var string|null
41
     */
42
    public ?string $path = null;
43
44
    /**
45
     * @param string|array|null $name Route name or annotation parameters.
46
     * @param string|null       $path Route path.
47
     *
48
     * @throws ReflectionException
49
     */
50
    public function __construct(
51
        $name = null,
52
        ?string $path = null
53
    ) {
54
        $this->path = $path;
55
56
        if (is_array($name)) {
57
            $this->initAnnotation($name);
58
        } else {
59
            $this->name = $name;
60
        }
61
    }
62
63
}
64