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

Reader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 31
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 17 3
A getAnnotationReader() 0 10 2
1
<?php
2
3
namespace Chrisyue\PhpM3u8\M3u8\PropertyReader;
4
5
use Doctrine\Common\Annotations\AnnotationReader;
6
use Doctrine\Common\Annotations\AnnotationRegistry;
7
8
/**
9
 * @Annotation
10
 */
11
class Reader implements PropertyReaderInterface
12
{
13
    public function read($class, $type)
14
    {
15
        $reader = $this->getAnnotationReader();
16
        $class = new \ReflectionClass($class);
17
18
        $annots = [];
19
        foreach ($class->getProperties() as $property) {
20
            $annot = $reader->getPropertyAnnotation($property, $type);
21
            if (null === $annot) {
22
                continue;
23
            }
24
25
            $annots[$property->getName()] = $annot;
26
        }
27
28
        return $annots;
29
    }
30
31
    protected function getAnnotationReader()
32
    {
33
        static $reader;
34
        if (null === $reader) {
35
            AnnotationRegistry::registerLoader('class_exists');
0 ignored issues
show
Deprecated Code introduced by
The method Doctrine\Common\Annotati...istry::registerLoader() has been deprecated with message: this method is deprecated and will be removed in doctrine/annotations 2.0 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists')

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
36
            $reader = new AnnotationReader();
37
        }
38
39
        return $reader;
40
    }
41
}
42