supportsLogicKeywords()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * File containing the {@see \Mailcode\Mailcode_Commands_Command_ShowURL} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Commands
7
 * @see \Mailcode\Mailcode_Commands_Command_ShowURL
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
use Mailcode\Interfaces\Commands\TrackableInterface;
15
use Mailcode\Interfaces\Commands\Validation\QueryParamsInterface;
16
use Mailcode\Interfaces\Commands\Validation\TrackingIDInterface;
17
use Mailcode\Interfaces\Commands\Validation\NoTrackingInterface;
18
use Mailcode\Interfaces\Commands\Validation\ShortenInterface;
19
use Mailcode\Traits\Commands\Validation\QueryParamsTrait;
20
use Mailcode\Traits\Commands\Validation\TrackingIDTrait;
21
use Mailcode\Traits\Commands\Validation\NoTrackingTrait;
22
use Mailcode\Traits\Commands\Validation\ShortenTrait;
23
24
/**
25
 * Mailcode command: `showurl` to format and display a URL
26
 * with or without tracking. The URL is specified as the
27
 * content of the command, to allow Mailcode syntax to build
28
 * the URL or retrieve it from variables.
29
 *
30
 * @package Mailcode
31
 * @subpackage Commands
32
 * @author Sebastian Mordziol <[email protected]>
33
 */
34
class Mailcode_Commands_Command_ShowURL
35
    extends Mailcode_Commands_Command
36
    implements
37
    Mailcode_Interfaces_Commands_ProtectedContent,
38
    TrackableInterface,
39
    QueryParamsInterface,
40
    ShortenInterface
41
{
42
    use Mailcode_Traits_Commands_ProtectedContent;
43
    use NoTrackingTrait;
44
    use TrackingIDTrait;
45
    use QueryParamsTrait;
46
    use ShortenTrait;
47
48
    public function getName() : string
49
    {
50
        return 'showurl';
51
    }
52
53
    public function getLabel() : string
54
    {
55
        return t('Show URL with or without tracking.');
56
    }
57
58
    public function supportsType(): bool
59
    {
60
        return false;
61
    }
62
63
    public function supportsURLEncoding() : bool
64
    {
65
        return false;
66
    }
67
68
    public function getDefaultType() : string
69
    {
70
        return '';
71
    }
72
73
    public function requiresParameters(): bool
74
    {
75
        return true;
76
    }
77
78
    public function supportsLogicKeywords() : bool
79
    {
80
        return false;
81
    }
82
83
    protected function getValidations() : array
84
    {
85
        return array(
86
            Mailcode_Interfaces_Commands_ProtectedContent::VALIDATION_NAME_CONTENT_ID,
87
            TrackingIDInterface::VALIDATION_NAME_TRACKING_ID,
88
            QueryParamsInterface::VALIDATION_NAME_QUERY_PARAMS,
89
            Mailcode_Interfaces_Commands_ProtectedContent::VALIDATION_NAME_NESTED_MAILCODE,
90
            ShortenInterface::VALIDATION_NAME_SHORTEN,
91
        );
92
    }
93
94
    public function generatesContent() : bool
95
    {
96
        return true;
97
    }
98
99
    public function getURL() : string
100
    {
101
        return $this->getContentTrimmed();
102
    }
103
104
    public function isMailcodeEnabled() : bool
105
    {
106
        return true;
107
    }
108
}
109