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

BaseValidateComponent::getAuthManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Itstructure\RbacModule\components;
4
5
use Yii;
6
use yii\base\{Component, InvalidConfigException};
7
use yii\rbac\ManagerInterface;
8
9
/**
10
 * Class BaseValidateComponent
11
 *
12
 * @property ManagerInterface $authManager
13
 *
14
 * @package Itstructure\RbacModule\components
15
 */
16
class BaseValidateComponent extends Component
17
{
18
    /**
19
     * Auth manager.
20
     *
21
     * @var ManagerInterface
22
     */
23
    private $authManager;
24
25
    /**
26
     * Initialize.
27
     */
28 View Code Duplication
    public function init()
0 ignored issues
show
Duplication introduced by
This method 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...
29
    {
30
        if (null === $this->authManager){
31
            $this->setAuthManager(Yii::$app->authManager);
32
        }
33
34
        if (null === $this->authManager){
35
            throw new InvalidConfigException('The authManager is not defined.');
36
        }
37
    }
38
39
    /**
40
     * Returns the authManager (RBAC).
41
     *
42
     * @return ManagerInterface
43
     */
44
    public function getAuthManager(): ManagerInterface
45
    {
46
        return $this->authManager;
47
    }
48
49
    /**
50
     * Set authManager (RBAC).
51
     *
52
     * @param ManagerInterface $authManager
53
     */
54
    public function setAuthManager(ManagerInterface $authManager): void
55
    {
56
        $this->authManager = $authManager;
57
    }
58
}
59