AbstractCollector::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Leaditin\Annotations\Collector;
6
7
use Leaditin\Annotations\Reader\ReaderInterface;
8
use Leaditin\Annotations\Reflection;
9
10
/**
11
 * Class AbstractCollector
12
 *
13
 * @package Leaditin\Annotations\Collector
14
 * @author Igor Vuckovic <[email protected]>
15
 */
16
abstract class AbstractCollector implements CollectorInterface
17
{
18
    /** @var ReaderInterface */
19
    protected $reader;
20
21
    /** @var Reflection[] */
22
    protected $reflections;
23
24
    /**
25
     * @param ReaderInterface $reader
26
     */
27 1
    public function __construct(ReaderInterface $reader)
28
    {
29 1
        $this->reader = $reader;
30 1
        $this->reflections = [];
31 1
    }
32
33
    /**
34
     * @param string $class
35
     * @return Reflection
36
     */
37 1
    protected function get(string $class) : Reflection
38
    {
39 1
        return $this->reflections[$class];
40
    }
41
42
    /**
43
     * @param string $class
44
     * @param Reflection $reflection
45
     */
46 1
    protected function set(string $class, Reflection $reflection)
47
    {
48 1
        $this->reflections[$class] = $reflection;
49 1
    }
50
51
    /**
52
     * @param string $class
53
     * @return bool
54
     */
55 1
    protected function has(string $class) : bool
56
    {
57 1
        return array_key_exists($class, $this->reflections);
58
    }
59
60
    /**
61
     * @param string $class
62
     * @param Reflection $reflection
63
     */
64
    abstract protected function write(string $class, Reflection $reflection);
65
}
66