IndexController::getPlugin()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: dsmrt
5
 * Date: 3/18/18
6
 * Time: 10:00 PM
7
 */
8
9
namespace flipbox\saml\sp\controllers\cp\view\keychain;
10
11
use craft\base\Plugin;
12
use flipbox\keychain\controllers\cp\view\AbstractGeneralController;
13
use flipbox\saml\sp\Saml;
14
15
class IndexController extends AbstractGeneralController
16
{
17
    /**
18
     * @return Plugin
19
     */
20
    protected function getPlugin(): Plugin
21
    {
22
        return Saml::getInstance();
23
    }
24
25
    /**
26
     * @param array $variables
27
     * @return array
28
     */
29
    protected function beforeRender(array $variables = [])
30
    {
31
        $request = \Craft::$app->request;
32
33
        $key = null;
34
        $path = implode(
35
            '/',
36
            [
37
                $request->getSegment(2),
38
                $request->getSegment(3),
39
                $request->getSegment(4),
40
            ]
41
        );
42
43
        if (preg_match('#keychain/+$#', $path)) {
44
            $key = 'saml.keychain';
45
        }
46
47
        $variables['selectedSubnavItem'] = $key;
48
        return parent::beforeRender($variables);
49
    }
50
}
51