NestedSetsQueryTrait::roots()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @link https://github.com/paulzi/yii2-nested-sets
4
 * @copyright Copyright (c) 2015 PaulZi <[email protected]>
5
 * @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
6
 */
7
8
namespace paulzi\nestedsets;
9
10
/**
11
 * @author PaulZi <[email protected]>
12
 */
13
trait NestedSetsQueryTrait
14
{
15
    /**
16
     * @return \yii\db\ActiveQuery
17
     */
18 3
    public function roots()
19
    {
20
        /** @var \yii\db\ActiveQuery $this */
21 3
        $class = $this->modelClass;
22 3
        $model = new $class;
23 3
        return $this->andWhere([$model->leftAttribute => 1]);
24
    }
25
}
26