IndexController::beforeRender()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 18
cp 0
rs 9.584
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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