Completed
Push — master ( efd6c7...e843b5 )
by vistart
04:27
created

IndexAction::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 2
eloc 11
nc 2
nop 1
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\controllers\my;
14
15
use rhosocial\organization\Organization;
16
use rhosocial\user\User;
17
use Yii;
18
use yii\base\Action;
19
20
/**
21
 * @version 1.0
22
 * @author vistart <[email protected]>
23
 */
24
class IndexAction extends Action
25
{
26
    const ORG_ONLY = '1';
27
    const ORG_ALL = '0';
28
    /**
29
     * 
30
     * @param string $orgOnly
31
     * @return string rendering result.
32
     */
33
    public function run($orgOnly = self::ORG_ALL)
34
    {
35
        $user = Yii::$app->user->identity;
36
        /* @var $user User */
37
        $noInitOrg = $user->getNoInitOrganization();
38
        /* @var $noInitOrg Organization */
39
        $searchModel = $noInitOrg->getSearchModel();
40
        $dataProvider = $searchModel->search(Yii::$app->request->post());
41
        $query = ($orgOnly == self::ORG_ONLY) ? $user->getAtOrganizationsOnly() : $user->getAtOrganizations();
0 ignored issues
show
Unused Code introduced by
$query is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
42
        return $this->controller->render('index', [
43
            'dataProvider' => $dataProvider,
44
            'searchModel' => $searchModel,
45
            'user' => $user,
46
            'orgOnly' => $orgOnly == self::ORG_ONLY,
47
        ]);
48
    }
49
}
50