ServiceCombo   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 48
loc 48
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFilter() 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
 * Hosting Plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-hosting
6
 * @package   hipanel-module-hosting
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\widgets\combo;
12
13
use hiqdev\combo\Combo;
14
use yii\helpers\ArrayHelper;
15
16
/**
17
 * Class Service.
18
 */
19 View Code Duplication
class ServiceCombo extends Combo
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...
20
{
21
    /** {@inheritdoc} */
22
    public $name = 'name';
23
24
    /** {@inheritdoc} */
25
    public $type = 'hosting/service';
26
27
    /** {@inheritdoc} */
28
    public $url = '/hosting/service/index';
29
30
    /** {@inheritdoc} */
31
    public $_return = ['id', 'client', 'client_id', 'server', 'server_id', 'seller', 'seller_id', 'soft'];
32
33
    /** {@inheritdoc} */
34
    public $_rename = ['text' => 'name'];
35
36
    /** {@inheritdoc} */
37
    public $_filter = [
38
        'client' => 'client/client',
39
        'server' => 'server/server',
40
    ];
41
42
    /**
43
     * @var string the soft type, used by [[getFilter]] to filter by the soft type
44
     * @see getFilter()
45
     */
46
    public $softType;
47
48
    public $_pluginOptions = [
49
        'activeWhen' => [
50
            'server/server',
51
        ],
52
        'affects'    => [
53
            'client/seller' => 'seller',
54
            'client/client' => 'client',
55
            'server/server' => 'server',
56
        ],
57
    ];
58
59
    /** {@inheritdoc} */
60
    public function getFilter()
61
    {
62
        return ArrayHelper::merge(parent::getFilter(), [
63
            'soft_type' => ['format' => $this->softType],
64
        ]);
65
    }
66
}
67