Completed
Push — master ( 89b65c...bde278 )
by Alexander
02:30
created

MethodConditionFetcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConditions() 0 15 2
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 Doctrine\Common\Annotations\Reader;
14
use ReflectionClass;
15
16
class MethodConditionFetcher extends Fetcher
17
{
18
    /**
19
     * @param ReflectionClass $class
20
     * @param Reader $reader
21
     * @param string $methodName
22
     * @param array $contracts
23
     * @return array
24
     */
25 8
    public function getConditions(ReflectionClass $class, Reader $reader, $methodName, array $contracts = [])
26
    {
27 8
        $parentClass = $class->getParentClass();
28
29 8
        if (!$parentClass) {
30 8
            return $contracts;
31
        }
32
33 4
        $parentMethod = $parentClass->getMethod($methodName);
34 4
        $annotations = $reader->getMethodAnnotations($parentMethod);
35 4
        $contractAnnotations = $this->getContractAnnotations($annotations);
36 4
        $contracts = array_merge($contracts, $contractAnnotations);
37
38 4
        return $this->getConditions($parentClass, $reader, $methodName, $contracts);
39
    }
40
}
41