GetManagerTrait::setManager()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Pluggable themes for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-thememanager
6
 * @package   yii2-thememanager
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\thememanager;
12
13
use hiqdev\yii2\collection\Manager;
14
use Yii;
15
16
trait GetManagerTrait
17
{
18
    protected $_manager = 'themeManager';
19
20
    /**
21
     * Setter for manager.
22
     *
23
     * @var string|Manager component name of the theme manager object
24
     */
25
    public function setManager($manager)
26
    {
27
        $this->_manager = $manager;
28
    }
29
30
    /**
31
     * Getter for manager.
32
     *
33
     * @return ThemeManager
34
     */
35
    public function getManager()
36
    {
37
        if (!is_object($this->_manager)) {
38
            $this->_manager = Yii::$app->get($this->_manager);
39
        }
40
41
        return $this->_manager;
42
    }
43
}
44