ClassAndInterfaceTagRetriever   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 48
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 4
A getInterfacesTagList() 0 11 2
A getTagList() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the Prophecy.
5
 * (c) Konstantin Kudryashov <[email protected]>
6
 *     Marcello Duarte <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Prophecy\PhpDocumentor;
13
14
use phpDocumentor\Reflection\DocBlock\Tag\MethodTag as LegacyMethodTag;
15
use phpDocumentor\Reflection\DocBlock\Tags\Method;
16
17
/**
18
 * @author Théo FIDRY <[email protected]>
19
 *
20
 * @internal
21
 */
22
final class ClassAndInterfaceTagRetriever implements MethodTagRetrieverInterface
23
{
24
    private $classRetriever;
25
26
    public function __construct(MethodTagRetrieverInterface $classRetriever = null)
27
    {
28
        if (null !== $classRetriever) {
29
            $this->classRetriever = $classRetriever;
30
31
            return;
32
        }
33
34
        $this->classRetriever = class_exists('phpDocumentor\Reflection\DocBlockFactory') && class_exists('phpDocumentor\Reflection\Types\ContextFactory')
35
            ? new ClassTagRetriever()
36
            : new LegacyClassTagRetriever()
37
        ;
38
    }
39
40
    /**
41
     * @param \ReflectionClass $reflectionClass
42
     *
43
     * @return LegacyMethodTag[]|Method[]
44
     */
45
    public function getTagList(\ReflectionClass $reflectionClass)
46
    {
47
        return array_merge(
48
            $this->classRetriever->getTagList($reflectionClass),
49
            $this->getInterfacesTagList($reflectionClass)
50
        );
51
    }
52
53
    /**
54
     * @param \ReflectionClass $reflectionClass
55
     *
56
     * @return LegacyMethodTag[]|Method[]
57
     */
58
    private function getInterfacesTagList(\ReflectionClass $reflectionClass)
59
    {
60
        $interfaces = $reflectionClass->getInterfaces();
61
        $tagList = array();
62
63
        foreach($interfaces as $interface) {
64
            $tagList = array_merge($tagList, $this->classRetriever->getTagList($interface));
65
        }
66
67
        return $tagList;
68
    }
69
}
70