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

Url   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 2
dl 0
loc 53
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
A displayName() 0 4 1
A getUrl() 0 4 2
A inputHtml() 0 12 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