Completed
Push — 10.x ( c22aa1 )
by Tim
12:07
created

NamespacedCachePoolFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 5
loc 5
c 0
b 0
f 0
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Connection\NamespacedArrayCachePoolFactory
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2019 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Connection;
22
23
use Cache\Namespaced\NamespacedCachePool;
24
use TechDivision\Import\ConfigurationInterface;
25
26
/**
27
 * Factory for namespaced array cache pool instances.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2019 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import
33
 * @link      http://www.techdivision.com
34
 */
35 View Code Duplication
class NamespacedCachePoolFactory implements CachePoolFactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
{
37
38
    /**
39
     * The configuration instance.
40
     *
41
     * @var \TechDivision\Import\ConfigurationInterface
42
     */
43
    protected $configuration;
44
45
    /**
46
     * The cache factory instance.
47
     *
48
     * @var \TechDivision\Import\Connection\CachePoolFactoryInterface
49
     */
50
    protected $cachePoolFactory;
51
52
    /**
53
     * Initialize the cache adapter factory with the passed configuration instances.
54
     * .
55
     * @param \TechDivision\Import\ConfigurationInterface               $configuration    The configuration instance
56
     * @param \TechDivision\Import\Connection\CachePoolFactoryInterface $cachePoolFactory The cache factory instance
57
     */
58
    public function __construct(ConfigurationInterface $configuration, CachePoolFactoryInterface $cachePoolFactory)
59
    {
60
        $this->configuration = $configuration;
61
        $this->cachePoolFactory = $cachePoolFactory;
62
    }
63
64
    /**
65
     * Creates and returns the cache pool instance.
66
     *
67
     * @return \Cache\Namespaced\NamespacedCachePool The namespaced cache pool instance
68
     */
69
    public function createCachePool()
70
    {
71
        return new NamespacedCachePool($this->cachePoolFactory->createCachePool(), $this->configuration->getSerial());
0 ignored issues
show
Compatibility introduced by
$this->cachePoolFactory->createCachePool() of type object<Psr\Cache\CacheItemPoolInterface> is not a sub-type of object<Cache\Hierarchy\HierarchicalPoolInterface>. It seems like you assume a child interface of the interface Psr\Cache\CacheItemPoolInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
72
    }
73
}
74