ModuleTrait::getModule()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 0
1
<?php
2
3
namespace hauntd\vote\traits;
4
5
use Yii;
6
use hauntd\vote\Module;
7
use yii\base\InvalidConfigException;
8
9
/**
10
 * Trait ModuleTrait
11
 * @package hauntd\vote\traits
12
 */
13
trait ModuleTrait
14
{
15
    /**
16
     * @return \hauntd\vote\Module|\yii\base\Module
17
     * @throws InvalidConfigException
18
     */
19
    public function getModule()
20
    {
21
        if (Yii::$app->hasModule('vote') && ($module = Yii::$app->getModule('vote')) instanceof Module) {
22
            return $module;
23
        }
24
25
        throw new InvalidConfigException('Module "vote" is not set.');
26
    }
27
}
28