Completed
Pull Request — master (#39)
by
unknown
05:19 queued 02:35
created

CustomOffer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 19.44 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTagProperties() 0 5 1
A getYmlAttributes() 0 9 1
A rules() 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
 * Created by PhpStorm.
4
 * User: execut
5
 * Date: 4/28/17
6
 * Time: 10:11 AM
7
 */
8
9
namespace pastuhov\ymlcatalog\models;
10
11
12
use yii\helpers\ArrayHelper;
13
14
class CustomOffer extends Offer
15
{
16
    public $model;
17
    public $vendor;
18
    public $vendorCode;
19
    public $typePrefix;
20
    public $type = 'vendor.model';
21
    /**
22
     * @inheritdoc
23
     */
24
    public static function getTagProperties() {
25
        return ArrayHelper::merge(parent::getTagProperties(), [
26
            'type'
27
        ]);
28
    }
29
30
    public function getYmlAttributes()
31
    {
32
        return ArrayHelper::merge(parent::getYmlAttributes(), [
33
            'model',
34
            'vendor',
35
            'vendorCode',
36
            'typePrefix',
37
        ]);
38
    }
39
    /**
40
     * @inheritdoc
41
     */
42 View Code Duplication
    public function rules()
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...
43
    {
44
        return ArrayHelper::merge(parent::rules(), [
45
            [['type', 'model', 'vendor'], 'required'],
46
            [['model', 'vendor', 'vendorCode', 'typePrefix'], 'string', 'max' => 200],
47
        ]);
48
    }
49
}