Completed
Pull Request — master (#10)
by
unknown
02:46
created

InvariantFetcher::getConditions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 3
crap 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 InvariantFetcher extends Fetcher
17
{
18
    /**
19
     * @param ReflectionClass $class
20
     * @param Reader $reader
21
     * @param array $contracts
22
     * @return array
23
     */
24 7
    public function getConditions(ReflectionClass $class, Reader $reader, array $contracts = [])
25
    {
26 7
        $parentClass = $class->getParentClass();
27
28 7
        if (!$parentClass) {
29 7
            return $contracts;
30
        }
31
32 4
        $annotations = $reader->getClassAnnotations($parentClass);
33 4
        $contractAnnotations = $this->getContractAnnotations($annotations);
34 4
        $contracts = array_merge($contracts, $contractAnnotations);
35
36 4
        return $this->getConditions($parentClass, $reader, $contracts);
37
    }
38
}
39