NodeAlMp   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 45
loc 45
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 4 4 1
A find() 4 4 1
A behaviors() 12 12 1
A transactions() 6 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
 * @link https://github.com/paulzi/yii2-auto-tree
4
 * @copyright Copyright (c) 2015 PaulZi <[email protected]>
5
 * @license MIT (https://github.com/paulzi/yii2-auto-tree/blob/master/LICENSE)
6
 */
7
8
namespace paulzi\autotree\tests\models;
9
10
use paulzi\adjacencyList\AdjacencyListBehavior;
11
use paulzi\materializedPath\MaterializedPathBehavior;
12
use paulzi\autotree\AutoTreeTrait;
13
14
/**
15
 * @author PaulZi <[email protected]>
16
 *
17
 * @property integer $id
18
 * @property integer $parent_id
19
 * @property integer $sort
20
 * @property integer $tree
21
 * @property integer $lft
22
 * @property integer $rgt
23
 * @property integer $depth
24
 * @property string $path
25
 * @property string $slug
26
 *
27
 * @property NodeAlMp[] $parents
28
 * @property NodeAlMp $parent
29
 * @property NodeAlMp $root
30
 * @property NodeAlMp[] $descendants
31
 * @property NodeAlMp[] $children
32
 * @property NodeAlMp[] $leaves
33
 * @property NodeAlMp $prev
34
 * @property NodeAlMp $next
35
 *
36
 * @method static NodeAlMp|null findOne() findOne($condition)
37
 *
38
 * @mixin AdjacencyListBehavior
39
 * @mixin MaterializedPathBehavior
40
 */
41 View Code Duplication
class NodeAlMp extends \yii\db\ActiveRecord
0 ignored issues
show
Duplication introduced by
This class 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...
42
{
43
    use AutoTreeTrait;
44
45
    /**
46
     * @inheritdoc
47
     */
48 21
    public static function tableName()
49
    {
50 21
        return '{{%tree}}';
51
    }
52
    /**
53
     * @inheritdoc
54
     */
55 21
    public function behaviors()
56
    {
57
        return [
58
            [
59 21
                'class'         => AdjacencyListBehavior::className(),
60
                'sortable'      => false,
61
            ],
62
            [
63 21
                'class'         => MaterializedPathBehavior::className(),
64
            ],
65
        ];
66
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71 10
    public function transactions()
72
    {
73
        return [
74 10
            self::SCENARIO_DEFAULT => self::OP_ALL,
75
        ];
76
    }
77
78
    /**
79
     * @return NodeQuery
80
     */
81 21
    public static function find()
82
    {
83 21
        return new NodeQuery(get_called_class());
84
    }
85
}