Completed
Push — master ( 0f341b...3e6c76 )
by Tobias
21:32
created

RouterFactory::get()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 4
nop 3
1
<?php
2
3
/*
4
 * This file is part of php-cache\cache-bundle package.
5
 *
6
 * (c) 2015-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\CacheBundle\Factory;
13
14
use Cache\CacheBundle\Routing\CachingRouter;
15
use Cache\Prefixed\PrefixedCachePool;
16
use Cache\Taggable\TaggablePSR6PoolAdapter;
17
use Psr\Cache\CacheItemPoolInterface;
18
use Symfony\Component\Routing\RouterInterface;
19
20
/**
21
 * @author Tobias Nyholm <[email protected]>
22
 */
23 View Code Duplication
class RouterFactory
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...
24
{
25
    /**
26
     * @param CacheItemPoolInterface $pool
27
     * @param RouterInterface        $router
28
     * @param array                  $config
29
     *
30
     * @return CachingRouter
31
     */
32
    public static function get(CacheItemPoolInterface $pool, RouterInterface $router, array $config)
33
    {
34
        if ($config['use_tagging']) {
35
            $pool = TaggablePSR6PoolAdapter::makeTaggable($pool);
36
        }
37
38
        if (!empty($config['prefix'])) {
39
            $pool = new PrefixedCachePool($pool, $config['prefix']);
40
        }
41
42
        return new CachingRouter($pool, $router, $config);
43
    }
44
}
45