MemoryCollector::read()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
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