DashboardPanelQuery   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 51
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A enabled() 0 4 1
A orderBySort() 0 4 1
A all() 0 4 1
A allCanView() 0 11 3
A one() 0 4 1
1
<?php
2
3
namespace cornernote\dashboard\models\query;
4
5
use yii\db\ActiveQuery;
6
use cornernote\dashboard\models\DashboardPanel;
7
use cornernote\dashboard\components;
8
9
/**
10
 * This is the ActiveQuery class for [[\cornernote\dashboard\models\DashboardPanel]].
11
 *
12
 * @see DashboardPanel
13
 */
14
class DashboardPanelQuery extends ActiveQuery
15
{
16
    /**
17
     * @return static
18
     */
19
    public function enabled()
20
    {
21
        return $this->andWhere(['enabled' => 1]);
22
    }
23
24
    /**
25
     * @return static
26
     */
27
    public function orderBySort()
28
    {
29
        return $this->orderBy(['sort' => SORT_ASC]);
30
    }
31
32
    /**
33
     * @inheritdoc
34
     * @return DashboardPanel[]|array
35
     */
36
    public function all($db = null)
37
    {
38
        return parent::all($db);
39
    }
40
41
    /**
42
	 * @return DashboardPanel[]|array
43
	 */
44
	public function allCanView($db = null)
45
	{
46
		$models = parent::all($db);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (all() instead of allCanView()). Are you sure this is correct? If so, you might want to change this to $this->all().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
47
		foreach ($models as $k => $model) {
48
			if (!components\DashboardPanelAccess::userHasAccess($model->name)) {
49
				unset($models[$k]);
50
			}
51
		}
52
53
		return $models;
54
	}
55
56
	/**
57
	 * @inheritdoc
58
	 * @return DashboardPanel|array|null
59
	 */
60
    public function one($db = null)
61
    {
62
        return parent::one($db);
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::one($db); of type yii\db\ActiveRecord|array|null adds the type yii\db\ActiveRecord to the return on line 62 which is incompatible with the return type declared by the interface yii\db\QueryInterface::one of type array|boolean.
Loading history...
63
    }
64
}