Completed
Push — master ( 3082b8...6de04a )
by Andrii
04:26
created

GetModuleTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 26
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setModule() 0 4 1
A getModule() 0 8 2
1
<?php
2
3
/*
4
 * Yii2 module for language switching
5
 *
6
 * @link      https://github.com/hiqdev/yii2-language
7
 * @package   yii2-language
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hiqdev\yii2\language;
13
14
use Yii;
15
16
/**
17
 * Get module trait.
18
 * Provides get/set module methods.
19
 *
20
 * @property Module $module The module to be used, can be found by default.
21
 */
22
trait GetModuleTrait
23
{
24
    protected $_module = 'language';
25
26
    /**
27
     * Setter for module.
28
     * @var string|Module module name or the module object.
29
     */
30
    public function setModule($module)
31
    {
32
        $this->_module = $module;
33
    }
34
35
    /**
36
     * Getter for module.
37
     * @return Module
38
     */
39
    public function getModule()
40
    {
41
        if (!is_object($this->_module)) {
42
            $this->_module = Yii::$app->getModule($this->_module);
43
        }
44
45
        return $this->_module;
46
    }
47
}
48