RbacValidateComponent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A setModel() 0 14 2
1
<?php
2
3
namespace Itstructure\RbacModule\components;
4
5
use yii\base\{Model, InvalidConfigException};
6
use Itstructure\RbacModule\{
7
    interfaces\ModelInterface,
8
    interfaces\ValidateComponentInterface
9
};
10
11
/**
12
 * Class RbacValidateComponent
13
 * Component class for RBAC.
14
 *
15
 * @package Itstructure\RbacModule\components
16
 */
17
class RbacValidateComponent extends BaseValidateComponent implements ValidateComponentInterface
18
{
19
    /**
20
     * Sets Rbac model.
21
     *
22
     * @param Model $model
23
     *
24
     * @throws InvalidConfigException
25
     *
26
     * @return ModelInterface
27
     */
28
    public function setModel(Model $model): ModelInterface
29
    {
30
        if (!($model instanceof ModelInterface)) {
31
32
            $modelClass = (new\ReflectionClass($model));
0 ignored issues
show
Bug introduced by
The function ReflectionClass was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
            $modelClass = (/** @scrutinizer ignore-call */ new\ReflectionClass($model));
Loading history...
33
34
            throw new InvalidConfigException($modelClass->getNamespaceName() .
35
                '\\' . $modelClass->getShortName().' class  must be implemented from 
36
                Itstructure\RbacModule\interfaces\ModelInterface.');
37
        }
38
39
        $model->setAuthManager($this->authManager);
40
41
        return $model;
42
    }
43
}
44