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

RouteReader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRoutes() 0 13 3
A isSupported() 0 3 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