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

ExternalIdentity::getSamlPlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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