Passed
Push — master ( f2dea1...58a092 )
by Nate
04:47
created

ModelWithId   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 41.07 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 23
loc 56
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A idRules() 23 23 1
A idAttributeLabel() 0 8 1
A getId() 0 4 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
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/spark/blob/master/LICENSE
6
 * @link       https://github.com/flipbox/spark
7
 */
8
9
namespace flipbox\spark\models\traits;
10
11
use Craft;
12
use flipbox\spark\helpers\ModelHelper;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 1.2.0
17
 */
18
trait ModelWithId
19
{
20
21
    /**
22
     * @var integer
23
     */
24
    public $id;
25
26
    /**
27
     * @inheritdoc
28
     */
29 View Code Duplication
    protected function idRules()
1 ignored issue
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...
30
    {
31
32
        return [
33
            [
34
                [
35
                    'id'
36
                ],
37
                'number',
38
                'integerOnly' => true
39
            ],
40
            [
41
                [
42
                    'id'
43
                ],
44
                'safe',
45
                'on' => [
46
                    ModelHelper::SCENARIO_DEFAULT
47
                ]
48
            ]
49
        ];
50
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    protected function idAttributeLabel()
57
    {
58
59
        return [
60
            'id' => Craft::t('app', 'Id')
61
        ];
62
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68
    public function getId()
69
    {
70
        return $this->id;
71
    }
72
73
}
74