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

RouterFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 22
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 12 12 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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