Completed
Pull Request — master (#6)
by
unknown
04:50
created

Shop   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 45.16 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 2 Features 1
Metric Value
wmc 3
c 4
b 2
f 1
lcom 0
cbo 1
dl 28
loc 62
ccs 0
cts 36
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B rules() 28 28 1
A getYmlBody() 0 10 2

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
namespace pastuhov\ymlcatalog\models;
3
4
class Shop extends BaseModel
5
{
6
    /**
7
     * @inheritdoc
8
     */
9
    public static $tag = false;
10
11
    public $name;
12
    public $company;
13
    public $url;
14
    public $platform;
15
    public $version;
16
    public $agency;
17
    public $email;
18
    public $cpa;
19
20
    /**
21
     * @inheritdoc
22
     */
23 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...
24
    {
25
        return [
26
            [
27
                ['name', 'company', 'url'],
28
                'required',
29
            ],
30
            [
31
                ['name'],
32
                'string',
33
                'max' => 20,
34
            ],
35
            [
36
                ['company', 'url', 'platform', 'version', 'agency', 'email'],
37
                'string',
38
                'max' => 255,
39
            ],
40
            [
41
                ['email'],
42
                'email',
43
            ],
44
            [
45
                ['cpa'],
46
                'in',
47
                'range' => ['1', '2'],
48
            ],
49
        ];
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    protected function getYmlBody()
56
    {
57
        $string = '';
58
59
        foreach ($this->getYmlAttributes() as $attribute) {
60
            $string .= $this->getYmlAttribute($attribute);
61
        }
62
63
        return $string;
64
    }
65
}
66