Passed
Push — master ( c28222...9253d7 )
by Sebastian
02:41
created

Mailcode_Commands_ShowBase   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 23
c 2
b 0
f 1
dl 0
loc 57
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultType() 0 3 1
A supportsType() 0 3 1
A supportsLogicKeywords() 0 3 1
A resolveValidations() 0 6 1
A requiresParameters() 0 3 1
A validateSyntax_urldeencode() 0 7 3
A supportsURLEncoding() 0 3 1
A generatesContent() 0 3 1
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Commands_IfBase} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Commands
7
 * @see Mailcode_Commands_IfBase
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Abstract base class for IF commands (IF, ELSEIF).
16
 *
17
 * @package Mailcode
18
 * @subpackage Commands
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
abstract class Mailcode_Commands_ShowBase
22
    extends Mailcode_Commands_Command
23
    implements
24
    Mailcode_Commands_Command_Type_Standalone,
25
    Mailcode_Interfaces_Commands_Variable,
26
    Mailcode_Interfaces_Commands_URLEncode,
27
    Mailcode_Interfaces_Commands_URLDecode
28
{
29
    use Mailcode_Traits_Commands_Validation_Variable;
30
    use Mailcode_Traits_Commands_Validation_URLEncode;
31
    use Mailcode_Traits_Commands_Validation_URLDecode;
32
33
    public function supportsURLEncoding() : bool
34
    {
35
        return true;
36
    }
37
38
    public function requiresParameters(): bool
39
    {
40
        return true;
41
    }
42
43
    public function generatesContent() : bool
44
    {
45
        return true;
46
    }
47
48
    public function supportsLogicKeywords() : bool
49
    {
50
        return false;
51
    }
52
53
    public function supportsType(): bool
54
    {
55
        return false;
56
    }
57
58
    public function getDefaultType() : string
59
    {
60
        return '';
61
    }
62
63
    protected function resolveValidations(): array
64
    {
65
        $validations = parent::resolveValidations();
66
        $validations[] = 'urldeencode';
67
68
        return $validations;
69
    }
70
71
    protected function validateSyntax_urldeencode() : void
72
    {
73
        if($this->isURLEncoded() && $this->getURLDecodeToken() !== null)
74
        {
75
            $this->validationResult->makeError(
76
                t('Cannot enable URL decoding and encoding at the same time.'),
77
                Mailcode_Commands_CommonConstants::VALIDATION_URL_DE_AND_ENCODE_ENABLED
78
            );
79
        }
80
    }
81
}