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

SimpleOffer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 36.67 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 2 Features 1
Metric Value
wmc 2
c 3
b 2
f 1
lcom 0
cbo 2
dl 11
loc 30
ccs 0
cts 0
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getYmlAttributes() 0 9 1
A rules() 11 11 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
namespace pastuhov\ymlcatalog\models;
4
5
use yii\base\Exception;
6
use yii\base\InvalidParamException;
7
use yii\helpers\ArrayHelper;
8
9
class SimpleOffer extends Offer
10
{
11
    public $name;
12
    public $model;
13
    public $vendor;
14
    public $vendorCode;
15
    public function getYmlAttributes()
16
    {
17
        return ArrayHelper::merge(parent::getYmlAttributes(), [
18
            'name',
19
            'model',
20
            'vendor',
21
            'vendorCode',
22
        ]);
23
    }
24
    /**
25
     * @inheritdoc
26
     */
27 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...
28
    {
29
        return ArrayHelper::merge(parent::rules(), [
30
            [['name'], 'required'],
31
            [
32
                ['name', 'vendor', 'vendorCode', 'model'],
33
                'string',
34
                'max' => 120,
35
            ],
36
        ]);
37
    }
38
}
39