MailCombo   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 21.62 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 2
dl 8
loc 37
ccs 0
cts 14
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilter() 8 8 1
A getPluginOptions() 0 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
class MailCombo extends Combo
17
{
18
    /** {@inheritdoc} */
19
    public $type = 'hosting/mail';
20
21
    /** {@inheritdoc} */
22
    public $name = 'mail';
23
24
    /** {@inheritdoc} */
25
    public $url = '/hosting/mail/search';
26
27
    /** {@inheritdoc} */
28
    public $_return = ['id', 'account', 'server', 'client'];
29
30
    /** {@inheritdoc} */
31
    public $_rename = ['text' => 'mail'];
32
33
    public $activeWhen = ['server/server'];
34
35
    /** {@inheritdoc} */
36 View Code Duplication
    public function getFilter()
0 ignored issues
show
Duplication introduced by
This method 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...
37
    {
38
        return ArrayHelper::merge(parent::getFilter(), [
39
            'server' => 'server/server',
40
            'account' => 'hosting/account',
41
            'state' => ['format' => 'ok'],
42
        ]);
43
    }
44
45
    /** {@inheritdoc} */
46
    public function getPluginOptions($options = [])
47
    {
48
        return parent::getPluginOptions(ArrayHelper::merge([
49
            'activeWhen' => $this->activeWhen,
50
        ], $options));
51
    }
52
}
53