Passed
Pull Request — 1.x (#9)
by Marko
03:23
created

AbstractActionReader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getActions() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KunicMarko\SonataAnnotationBundle\Reader;
6
7
use KunicMarko\SonataAnnotationBundle\Annotation\AbstractAction;
8
9
/**
10
 * @author Marko Kunic <[email protected]>
11
 */
12
abstract class AbstractActionReader
13
{
14
    use AnnotationReaderTrait;
15
16
    public function getActions(\ReflectionClass $class, array $actions): array
17
    {
18
        foreach ($this->getClassAnnotations($class) as $annotation) {
19
            if ($this->isSupported($annotation)) {
20
                /** @var AbstractAction $annotation */
21
                $actions[random_int(-99999, 99999)]['template'] = $annotation->getTemplate();
22
            }
23
        }
24
25
        return $actions;
26
    }
27
28
    abstract protected function isSupported($annotation): bool;
29
}
30