Completed
Push — master ( 1223fc...6af157 )
by Damien
05:06
created

ExternalIdentity   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 35
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSamlPlugin() 0 4 1
A getStaticHtml() 0 16 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
    public function getStaticHtml($value, ElementInterface $element): string
35
    {
36
        if (! ($value instanceof Query)) {
37
            return '';
38
        }
39
        return \Craft::$app->getView()->renderTemplate(
40
            'saml-sp/_cp/fields/external-id',
41
            [
42
                'identities' => $value,
43
                'element'    => $element,
44
                'baseProviderUrl' => UrlHelper::cpUrl(
45
                    'saml-sp/metadata'
46
                ),
47
            ]
48
        );
49
    }
50
}
51