ChainFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAdapter() 0 4 1
A configureOptionResolver() 0 9 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\Chain\CachePoolChain;
15
use Symfony\Component\OptionsResolver\OptionsResolver;
16
17
/**
18
 * @author Aaron Scherer <[email protected]>
19
 */
20
final class ChainFactory extends AbstractAdapterFactory
21
{
22
    protected static $dependencies = [
23
        ['requiredClass' => 'Cache\Adapter\Chain\CachePoolChain', 'packageName' => 'cache/chain-adapter'],
24
    ];
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 1
    public function getAdapter(array $config)
30
    {
31 1
        return new CachePoolChain($config['services'], ['skip_on_failure' => $config['skip_on_failure']]);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 3
    protected static function configureOptionResolver(OptionsResolver $resolver)
38
    {
39 3
        parent::configureOptionResolver($resolver);
40
41 3
        $resolver->setRequired('services');
42 3
        $resolver->setAllowedTypes('services', ['array']);
43
44 3
        $resolver->setDefault('skip_on_failure', false);
45 3
    }
46
}
47