Completed
Push — master ( d62d29...27939e )
by Marko
02:28
created

RouteReader::getRoutes()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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