Completed
Push — master ( 5ab18b...9f1bcc )
by Igor
02:39
created

MemoryCollector::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Leaditin\Annotations\Collector;
6
7
use Leaditin\Annotations\Reflection;
8
9
/**
10
 * Class MemoryCollector
11
 *
12
 * @package Leaditin\Annotations\Collector
13
 * @author Igor Vuckovic <[email protected]>
14
 */
15
class MemoryCollector extends AbstractCollector
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 1
    public function read(string $class) : Reflection
21
    {
22 1
        if ($this->has($class) === false) {
23 1
            $this->write($class, $this->reader->read($class));
24
        }
25
26 1
        return $this->get($class);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 1
    protected function write(string $class, Reflection $reflection)
33
    {
34 1
        $this->set($class, $reflection);
35 1
    }
36
}
37