Completed
Push — master ( fe0f99...6b22ab )
by Nate
03:54
created

Url::getInputHtml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
ccs 0
cts 12
cp 0
rs 9.4285
cc 1
eloc 7
nc 1
nop 3
crap 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A Url::displayName() 0 4 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/link/license
6
 * @link       https://www.flipboxfactory.com/software/link/
7
 */
8
9
namespace flipbox\link\types;
10
11
use Craft;
12
use craft\base\ElementInterface;
13
use flipbox\link\fields\Link;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
class Url extends AbstractType
20
{
21
    /**
22
     * @var
23
     */
24
    public $url;
25
26
    /**
27
     * @var string
28
     */
29
    protected $identifier = 'url';
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function init()
35
    {
36
        parent::init();
37
        $this->identifier = 'url';
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public static function displayName(): string
44
    {
45
        return Craft::t('link', 'Url');
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getUrl(): string
52
    {
53
        return $this->url ?: '';
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function inputHtml(Link $field, TypeInterface $type = null, ElementInterface $element = null): string
60
    {
61
        return Craft::$app->getView()->renderTemplate(
62
            'link/_components/fieldtypes/Link/types/url/input',
63
            [
64
                'value' => $type,
65
                'element' => $element,
66
                'type' => $this,
67
                'field' => $field
68
            ]
69
        );
70
    }
71
}
72