Completed
Push — master ( 7a069b...4da1f4 )
by Paweł
11s
created

TenantAwareMetaKeyGenerator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 3
dl 27
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A generateKey() 6 6 1

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 the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2017 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2017 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\Twig\Cache\KeyGenerator;
16
17
use SWP\Bundle\ContentBundle\KeyGenerator\MetaKeyGenerator;
18
use SWP\Component\MultiTenancy\Context\TenantContextInterface;
19
20
/**
21
 * Key generator for meta objects.
22
 */
23 View Code Duplication
class TenantAwareMetaKeyGenerator extends MetaKeyGenerator
1 ignored issue
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
     * @var TenantContextInterface
27
     */
28
    protected $tenantContext;
29
30
    /**
31
     * MetaKeyGenerator constructor.
32
     *
33
     * @param TenantContextInterface $tenantContext
34
     */
35
    public function __construct(TenantContextInterface $tenantContext)
36
    {
37
        $this->tenantContext = $tenantContext;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function generateKey($meta)
44
    {
45
        $tenantCode = $this->tenantContext->getTenant()->getCode();
46
47
        return $tenantCode.'_'.parent::generateKey($meta);
48
    }
49
}
50