Passed
Push — master ( 26f9dc...b66765 )
by Marko
02:57
created

RouteReader::isSupported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KunicMarko\SonataAnnotationBundle\Reader;
6
7
use KunicMarko\SonataAnnotationBundle\Annotation\AddRoute;
8
use KunicMarko\SonataAnnotationBundle\Annotation\RemoveRoute;
9
10
/**
11
 * @author Marko Kunic <[email protected]>
12
 */
13
class RouteReader
14
{
15
    use AnnotationReaderTrait;
16
17
    public function getRoutes(\ReflectionClass $class): array
18
    {
19
        $addRoutes = [];
20
        $removeRoutes = [];
21
22
        foreach ($this->getClassAnnotations($class) as $annotation) {
23
            if ($this->isAddRoute($annotation)) {
24
                $addRoutes[$annotation->name] = $annotation;
25
                continue;
26
            }
27
28
            if ($this->isRemoveRoute($annotation)) {
29
                $removeRoutes[$annotation->name] = $annotation;
30
            }
31
        }
32
33
        return [$addRoutes, $removeRoutes];
34
    }
35
36
    private function isAddRoute($annotation): bool
37
    {
38
        return $annotation instanceof AddRoute;
39
    }
40
41
    private function isRemoveRoute($annotation): bool
42
    {
43
        return $annotation instanceof RemoveRoute;
44
    }
45
}
46