Completed
Branch dev (794b40)
by Andrey
04:12
created

PermissionSearch   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 4 1
A search() 0 19 1
1
<?php
2
3
namespace Itstructure\RbacModule\models;
4
5
use yii\data\ArrayDataProvider;
6
7
/**
8
 * Class PermissionSearch
9
 *
10
 * @package Itstructure\RbacModule\models
11
 */
12
class PermissionSearch extends Permission
13
{
14
    /**
15
     * Modify for custom search rules.
16
     *
17
     * @inheritdoc
18
     */
19
    public function rules()
20
    {
21
        return [];
22
    }
23
24
    /**
25
     * Creates data provider
26
     *
27
     * @param array $params
28
     *
29
     * @return ArrayDataProvider
30
     */
31
    public function search($params)
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        $allModels = $this->authManager->getPermissions();
0 ignored issues
show
Documentation introduced by
The property $authManager is declared private in Itstructure\RbacModule\models\Rbac. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
34
35
        $dataProvider = new ArrayDataProvider([
36
            'allModels' => $allModels,
37
        ]);
38
39
        /**
40
         * Modify for custom search conditions.
41
         *
42
        $this->load($params);
43
44
        if (!$this->validate()) {
45
            return $dataProvider;
46
        }*/
47
48
        return $dataProvider;
49
    }
50
}
51