LoginController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 39
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A actionIndex() 0 10 1
A getLoginTemplate() 0 10 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 */
6
7
namespace flipbox\saml\sp\controllers\cp\view;
8
9
use flipbox\saml\sp\Saml;
10
11
class LoginController extends GeneralController
12
{
13
    const TEMPLATE_INDEX = DIRECTORY_SEPARATOR . '_cp';
14
    const LOGIN_TEMPLATE = 'saml-sp/_cp/login';
15
    const LOGIN_TEMPLATE_34 = 'saml-sp/_cp/login34';
16
17
    public $allowAnonymous = [
18
        'index',
19
    ];
20
21
    /**
22
     * @return \yii\web\Response
23
     */
24
    public function actionIndex()
25
    {
26
        $variables = $this->getBaseVariables();
27
28
        $variables['providers'] = Saml::getInstance()->getProvider()->findByIdp();
29
        return $this->renderTemplate(
30
            $this->getLoginTemplate(),
31
            $variables
32
        );
33
    }
34
35
    /**
36
     * Support UI changes in 3.4
37
     * @return string
38
     */
39
    private function getLoginTemplate()
40
    {
41
        $useNewTemplate = version_compare(
42
            \Craft::$app->getVersion(),
43
            '3.4',
44
            '>='
45
        );
46
47
        return $useNewTemplate ? self::LOGIN_TEMPLATE_34 : self::LOGIN_TEMPLATE;
48
    }
49
}
50