Passed
Push — master ( b674ac...2bc77e )
by Kirill
04:21
created

AttributeReader   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 54
rs 10
c 1
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getParameterMetadata() 0 3 1
A getConstantMetadata() 0 3 1
A getClassMetadata() 0 3 1
A __construct() 0 5 2
A getPropertyMetadata() 0 3 1
A getFunctionMetadata() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Attributes package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Attributes;
13
14
final class AttributeReader extends Reader
15
{
16
    /**
17
     * @var FallbackAttributeReader|NativeAttributeReader
18
     */
19
    private $reader;
20
21
    /**
22
     * AttributeReader constructor.
23
     */
24
    public function __construct()
25
    {
26
        $this->reader = NativeAttributeReader::isAvailable()
27
            ? new NativeAttributeReader()
28
            : new FallbackAttributeReader();
29
    }
30
    /**
31
     * {@inheritDoc}
32
     */
33
    public function getClassMetadata(\ReflectionClass $class, string $name = null): iterable
34
    {
35
        return $this->reader->getClassMetadata($class, $name);
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     */
41
    public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable
42
    {
43
        return $this->reader->getFunctionMetadata($function, $name);
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public function getPropertyMetadata(\ReflectionProperty $property, string $name = null): iterable
50
    {
51
        return $this->reader->getPropertyMetadata($property, $name);
52
    }
53
54
    /**
55
     * {@inheritDoc}
56
     */
57
    public function getConstantMetadata(\ReflectionClassConstant $constant, string $name = null): iterable
58
    {
59
        return $this->reader->getConstantMetadata($constant, $name);
60
    }
61
62
    /**
63
     * {@inheritDoc}
64
     */
65
    public function getParameterMetadata(\ReflectionParameter $parameter, string $name = null): iterable
66
    {
67
        return $this->reader->getParameterMetadata($parameter, $name);
68
    }
69
}