Completed
Pull Request — develop (#27)
by Chris
01:52
created

PropertyReader::read()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 2
1
<?php
2
3
namespace Chrisyue\PhpM3u8\PropertyReader;
4
5
use Doctrine\Common\Annotations\AnnotationReader;
6
use Doctrine\Common\Annotations\AnnotationRegistry;
7
8
class PropertyReader implements PropertyReaderInterface
9
{
10
    private $annotReader;
11
12
    public function __construct(AnnotationReader $annotReader)
13
    {
14
        $this->annotReader = $annotReader;
15
    }
16
17
    public function read($class, $type)
18
    {
19
        $class = new \ReflectionClass($class);
20
21
        $annots = [];
22
        foreach ($class->getProperties() as $property) {
23
            $annot = $this->annotReader->getPropertyAnnotation($property, $type);
24
            if (null === $annot) {
25
                continue;
26
            }
27
28
            $annots[$property->getName()] = $annot;
29
        }
30
31
        return $annots;
32
    }
33
}
34