ModuleTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 4
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getModule() 0 7 3
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