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

AbstractFetcher   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 43
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A filterContractAnnotation() 0 14 3
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