ArrayFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 36
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAdapter() 0 10 2
A configureOptionResolver() 0 12 1
1
<?php
2
3
/*
4
 * This file is part of php-cache organization.
5
 *
6
 * (c) 2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Cache\AdapterBundle\Factory;
13
14
use Cache\Adapter\PHPArray\ArrayCachePool;
15
use Cache\Namespaced\NamespacedCachePool;
16
use Symfony\Component\OptionsResolver\OptionsResolver;
17
18
/**
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21
final class ArrayFactory extends AbstractAdapterFactory
22
{
23
    protected static $dependencies = [
24
        ['requiredClass' => 'Cache\Adapter\PHPArray\ArrayCachePool', 'packageName' => 'cache/array-adapter'],
25
    ];
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 1
    public function getAdapter(array $config)
31
    {
32 1
        $pool = new ArrayCachePool();
33
34 1
        if (null !== $config['pool_namespace']) {
35
            $pool = new NamespacedCachePool($pool, $config['pool_namespace']);
36
        }
37
38 1
        return $pool;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 6
    protected static function configureOptionResolver(OptionsResolver $resolver)
45
    {
46 6
        parent::configureOptionResolver($resolver);
47
48 6
        $resolver->setDefaults(
49
          [
50 6
            'pool_namespace' => null,
51
          ]
52
        );
53
54 6
        $resolver->setAllowedTypes('pool_namespace', ['string', 'null']);
55 6
    }
56
}
57