Completed
Pull Request — master (#835)
by Paweł
11:45
created

AuthorAssetLocationResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 20
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setTenantContext() 4 4 1
A getMediaBasePath() 7 7 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 Content Bundle.
5
 *
6
 * Copyright 2019 Sourcefabric z.ú. 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 2019 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\Resolver;
16
17
use SWP\Bundle\ContentBundle\Resolver\AssetLocationResolver as BaseAssetLocationResolver;
18
use SWP\Bundle\CoreBundle\Model\TenantInterface;
19
use SWP\Component\MultiTenancy\Context\TenantContextInterface;
20
21 View Code Duplication
class AuthorAssetLocationResolver extends BaseAssetLocationResolver
22
{
23
    protected $tenantContext;
24
25
    public function setTenantContext(TenantContextInterface $tenantContext): void
26
    {
27
        $this->tenantContext = $tenantContext;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getMediaBasePath(): string
34
    {
35
        /** @var TenantInterface $tenant */
36
        $tenant = $this->tenantContext->getTenant();
37
38
        return sprintf('swp/%s/authors', $tenant->getOrganization()->getCode());
39
    }
40
}
41