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

AbstractFetcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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
15
abstract class AbstractFetcher
16
{
17
    /**
18
     * @var string
19
     */
20
    protected $expectedAnnotationType;
21
22
    /**
23
     * @var Reader
24
     */
25
    protected $annotationReader;
26
27
    /**
28
     * @param string $expectedAnnotationType
29
     * @param Reader $reader
30
     */
31
    public function __construct($expectedAnnotationType, Reader $reader)
32
    {
33
        $this->expectedAnnotationType = $expectedAnnotationType;
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 34
    protected function filterContractAnnotation(array $annotations)
44
    {
45 34
        $contractAnnotations = [];
46
47 34
        foreach ($annotations as $annotation) {
48 12
            if ($annotation instanceof $this->expectedAnnotationType) {
49 12
                $contractAnnotations[] = $annotation;
50
            }
51
        }
52
53 34
        return $contractAnnotations;
54
    }
55
}
56