Completed
Push — master ( c3456a...b4bda7 )
by Damien
04:06 queued 38s
created

ExternalIdentity   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 30
ccs 3
cts 9
cp 0.3333
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
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\sp\traits\SamlPluginEnsured;
13
use yii\db\Query;
14
15
class ExternalIdentity extends AbstractExternalIdentity
16
{
17
18
    use SamlPluginEnsured;
19
20
    /**
21
     * @param $value
22
     * @param ElementInterface $element
23
     * @return string
24
     * @throws \Twig_Error_Loader
25
     * @throws \yii\base\Exception
26
     */
27 3
    public function getStaticHtml($value, ElementInterface $element): string
28
    {
29 3
        if (! ($value instanceof Query)) {
30 3
            return '';
31
        }
32
33
        return \Craft::$app->getView()->renderTemplate(
34
            'saml-sp/_cp/fields/external-id',
35
            [
36
                'identities' => $value,
37
                'element'    => $element,
38
                'baseProviderUrl' => UrlHelper::cpUrl(
39
                    'saml-sp/metadata'
40
                ),
41
            ]
42
        );
43
    }
44
}
45