Completed
Push — master ( 9eb8f3...27c704 )
by vistart
05:33
created

Module   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOrganization() 0 11 3
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\organization\web\organization;
14
15
use rhosocial\organization\Organization;
16
use Yii;
17
/**
18
 * @version 1.0
19
 * @author vistart <[email protected]>
20
 */
21
class Module extends \yii\base\Module
22
{
23
    const RESULT_SUCCESS = 'success';
24
    const RESULT_FAILED = 'failed';
25
    const SESSION_KEY_MESSAGE = 'session_key_message';
26
    const SESSION_KEY_RESULT = 'session_key_result';
27
28
    /**
29
     * Get organization.
30
     * @param Organization|string|integer $organization
31
     * @return Organization
32
     */
33
    public static function getOrganization($organization)
34
    {
35
        if (!$organization) {
36
            return null;
37
        }
38
        $class = Yii::$app->user->identity->organizationClass;
39
        if ($organization instanceof $class) {
40
            $organization = $organization->getID();
41
        }
42
        return $class::find()->guidOrId($organization)->one();
43
    }
44
}
45