AbstractCreator::getFqcn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * File was created 17.05.2016 06:29
4
 */
5
6
namespace PeekAndPoke\Component\Creator;
7
8
/**
9
 * @author Karsten J. Gerber <[email protected]>
10
 */
11
abstract class AbstractCreator implements Creator
12
{
13
    /** @var string */
14
    protected $fqcn;
15
16
    /**
17
     * WithoutConstructor constructor.
18
     *
19
     * @param \ReflectionClass $class
20
     */
21 18
    public function __construct(\ReflectionClass $class)
22
    {
23
        // ReflectionClass cannot be serialized (so we only store the FQCN)
24 18
        $this->fqcn = $class->name;
25 18
    }
26
27
    /**
28
     * @return string
29
     */
30 3
    public function getFqcn()
31
    {
32 3
        return $this->fqcn;
33
    }
34
35
    /**
36
     * @return \ReflectionClass
37
     */
38 18
    public function getClass()
39
    {
40 18
        static $registry = [];
41
42 18
        return $registry[$this->fqcn] ?? $registry[$this->fqcn] = new \ReflectionClass($this->fqcn);
43
    }
44
}
45