IndexController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 36
c 0
b 0
f 0
ccs 0
cts 22
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A beforeRender() 0 21 2
A getPlugin() 0 4 1
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