Passed
Pull Request — 1.x (#9)
by Marko
02:15
created

AddChildReader   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 getChildren() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KunicMarko\SonataAnnotationBundle\Reader;
6
7
use KunicMarko\SonataAnnotationBundle\Annotation\AddChild;
8
9
/**
10
 * @author Marko Kunic <[email protected]>
11
 */
12
final class AddChildReader
13
{
14
    use AnnotationReaderTrait;
15
16
    public function getChildren(\ReflectionClass $class): array
17
    {
18
        $children = [];
19
20
        foreach ($this->getClassAnnotations($class) as $annotation) {
21
            if (!$annotation instanceof AddChild) {
22
                continue;
23
            }
24
25
            $children[$annotation->getClass()] = $annotation->getField();
26
        }
27
28
        return $children;
29
    }
30
}
31