FactoryEntry   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 42
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A isFactory() 0 3 1
A createFromCacheParameters() 0 6 1
A __construct() 0 3 1
A getCacheParameters() 0 5 1
1
<?php
2
3
namespace Simply\Container\Entry;
4
5
use Psr\Container\ContainerInterface;
6
7
/**
8
 * Provides a wrapper for other entries to disallow caching of returned values.
9
 *
10
 * @author Riikka Kalliomäki <[email protected]>
11
 * @copyright Copyright (c) 2018 Riikka Kalliomäki
12
 * @license http://opensource.org/licenses/mit-license.php MIT License
13
 */
14
class FactoryEntry implements EntryInterface
15
{
16
    /** @var EntryInterface The actual container entry used to determine the value */
17
    private $entry;
18
19
    /**
20
     * FactoryType constructor.
21
     * @param EntryInterface $type The actual container entry used to determine the value
22
     */
23 1
    public function __construct(EntryInterface $type)
24
    {
25 1
        $this->entry = $type;
26 1
    }
27
28
    /** {@inheritdoc} */
29 1
    public static function createFromCacheParameters(array $parameters): EntryInterface
30
    {
31
        /** @var EntryInterface $class */
32 1
        [$class, $cacheParameters] = $parameters;
33
34 1
        return new static($class::createFromCacheParameters($cacheParameters));
35
    }
36
37
    /** {@inheritdoc} */
38 1
    public function getCacheParameters(): array
39
    {
40
        return [
41 1
            \get_class($this->entry),
42 1
            $this->entry->getCacheParameters(),
43
        ];
44
    }
45
46
    /** {@inheritdoc} */
47 1
    public function isFactory(): bool
48
    {
49 1
        return true;
50
    }
51
52
    /** {@inheritdoc} */
53 1
    public function getValue(ContainerInterface $container)
54
    {
55 1
        return $this->entry->getValue($container);
56
    }
57
}
58