AbstractCreator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 32
c 0
b 0
f 0
rs 10
ccs 8
cts 8
cp 1

3 Methods

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