Completed
Push — master ( 56c4be...a1e3bd )
by Alexander
7s
created

MethodConditionWithInheritDocFetcher   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 30
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConditions() 0 19 5
1
<?php
2
/**
3
 * PHP Deal framework
4
 *
5
 * @copyright Copyright 2014, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace PhpDeal\Contract\Fetcher\ParentClass;
12
13
use ReflectionClass;
14
15
class MethodConditionWithInheritDocFetcher extends AbstractFetcher
16
{
17
    /**
18
     * Fetches conditions from all parent method prototypes recursively
19
     *
20
     * @param ReflectionClass $class
21
     * @param string $methodName
22
     *
23
     * @return array
24
     */
25 19
    public function getConditions(ReflectionClass $class, $methodName)
26
    {
27 19
        $annotations   = [];
28 19
        $parentMethods = [];
29
        while (
30 19
            preg_match('/\@inheritdoc/i', $class->getMethod($methodName)->getDocComment())
31 19
            && ($class = $class->getParentClass())
32 19
            && $class->hasMethod($methodName)
33
        ) {
34 4
            $parentMethods[] = $class->getMethod($methodName);
35
        }
36
37 19
        foreach ($parentMethods as $parentMethod) {
38 4
            $annotations = array_merge($annotations, $this->annotationReader->getMethodAnnotations($parentMethod));
39
        }
40 19
        $contracts = $this->filterContractAnnotation($annotations);
41
42 19
        return $contracts;
43
    }
44
}
45