ClassTagRetriever   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getTagList() 0 21 4
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\Tags\Method;
15
use phpDocumentor\Reflection\DocBlockFactory;
16
use phpDocumentor\Reflection\Types\ContextFactory;
17
18
/**
19
 * @author Théo FIDRY <[email protected]>
20
 *
21
 * @internal
22
 */
23
final class ClassTagRetriever implements MethodTagRetrieverInterface
24
{
25
    private $docBlockFactory;
26
    private $contextFactory;
27
28
    public function __construct()
29
    {
30
        $this->docBlockFactory = DocBlockFactory::createInstance();
31
        $this->contextFactory = new ContextFactory();
32
    }
33
34
    /**
35
     * @param \ReflectionClass $reflectionClass
36
     *
37
     * @return Method[]
38
     */
39
    public function getTagList(\ReflectionClass $reflectionClass)
40
    {
41
        try {
42
            $phpdoc = $this->docBlockFactory->create(
43
                $reflectionClass,
44
                $this->contextFactory->createFromReflector($reflectionClass)
45
            );
46
47
            $methods = array();
48
49
            foreach ($phpdoc->getTagsByName('method') as $tag) {
50
                if ($tag instanceof Method) {
51
                    $methods[] = $tag;
52
                }
53
            }
54
55
            return $methods;
56
        } catch (\InvalidArgumentException $e) {
57
            return array();
58
        }
59
    }
60
}
61