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

PropertyReader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A read() 0 16 3
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