Completed
Push — master ( c96bfe...df0c48 )
by Marko
02:29
created

AbstractActionReader::getActions()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace KunicMarko\SonataAnnotationBundle\Reader;
4
5
use Doctrine\Common\Annotations\Reader;
6
7
/**
8
 * @author Marko Kunic <[email protected]>
9
 */
10
abstract class AbstractActionReader
11
{
12
    protected $annotationReader;
13
14
    public function __construct(Reader $annotationReader)
15
    {
16
        $this->annotationReader = $annotationReader;
17
    }
18
19
    public function getActions(\ReflectionClass $entity, array $actions): array
20
    {
21
        $annotations = $this->annotationReader->getClassAnnotations($entity);
22
23
        foreach ($annotations as $annotation) {
24
            if (!$this->isSupported($annotation)) {
25
                continue;
26
            }
27
28
            $actions[random_int(-99999, 99999)]['template'] = $annotation->template;
29
        }
30
31
        return $actions;
32
    }
33
34
    abstract protected function isSupported($annotation): bool;
35
}
36