Completed
Branch master (d9b923)
by Damien
01:32
created

ExternalIdentity   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 27.27%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSamlPlugin() 0 4 1
A getStaticHtml() 0 17 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 */
6
7
namespace flipbox\saml\sp\fields;
8
9
use craft\base\ElementInterface;
10
use craft\helpers\UrlHelper;
11
use flipbox\saml\core\fields\AbstractExternalIdentity;
12
use flipbox\saml\core\SamlPluginInterface;
13
use flipbox\saml\sp\Saml;
14
use yii\db\Query;
15
16
class ExternalIdentity extends AbstractExternalIdentity
17
{
18
19
    /**
20
     * @inheritdoc
21
     */
22
    protected function getSamlPlugin(): SamlPluginInterface
23
    {
24
        return Saml::getInstance();
25
    }
26
27
    /**
28
     * @param $value
29
     * @param ElementInterface $element
30
     * @return string
31
     * @throws \Twig_Error_Loader
32
     * @throws \yii\base\Exception
33
     */
34 3
    public function getStaticHtml($value, ElementInterface $element): string
35
    {
36 3
        if (! ($value instanceof Query)) {
37 3
            return '';
38
        }
39
40
        return \Craft::$app->getView()->renderTemplate(
41
            'saml-sp/_cp/fields/external-id',
42
            [
43
                'identities' => $value,
44
                'element'    => $element,
45
                'baseProviderUrl' => UrlHelper::cpUrl(
46
                    'saml-sp/metadata'
47
                ),
48
            ]
49
        );
50
    }
51
}
52