Completed
Push — master ( 51150f...078ca3 )
by
unknown
02:17
created

AbstractFetcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
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\Parent;
12
13
use Doctrine\Common\Annotations\Reader;
14
15
abstract class AbstractFetcher
16
{
17
    /**
18
     * @var string[]
19
     */
20
    protected $expectedAnnotationTypes;
21
22
    /**
23
     * @var Reader
24
     */
25
    protected $annotationReader;
26
27
    /**
28
     * @param string[] $expectedAnnotationTypes
29
     * @param Reader   $reader
30
     */
31
    public function __construct($expectedAnnotationTypes, Reader $reader)
32
    {
33
        $this->expectedAnnotationTypes = $expectedAnnotationTypes;
34
        $this->annotationReader        = $reader;
35
    }
36
37
    /**
38
     * Performs filtering of annotations by the requested class name
39
     *
40
     * @param array $annotations
41
     * @return array
42
     */
43 51
    protected function filterContractAnnotation(array $annotations)
44
    {
45 51
        $contractAnnotations = [];
46
47 51
        foreach ($annotations as $annotation) {
48 26
            $annotationClass = \get_class($annotation);
49
50 26
            if (\in_array($annotationClass, $this->expectedAnnotationTypes, true)) {
51 26
                $contractAnnotations[] = $annotation;
52
            }
53
        }
54
55 51
        return $contractAnnotations;
56
    }
57
}
58