Passed
Push — master ( 13a961...900cb1 )
by Sebastian
03:37
created

Mailcode_Commands_Command_ShowVariable   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 9
Bugs 0 Features 0
Metric Value
eloc 19
c 9
b 0
f 0
dl 0
loc 59
rs 10
wmc 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A requiresParameters() 0 3 1
A getLabel() 0 3 1
A getDefaultType() 0 3 1
A supportsLogicKeywords() 0 3 1
A getName() 0 3 1
A getValidations() 0 5 1
A validateSyntax_no_other_tokens() 0 10 2
A supportsType() 0 3 1
A generatesContent() 0 3 1
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Commands_Command_ShowVariable} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Commands
7
 * @see Mailcode_Commands_Command_ShowVariable
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Mailcode command: show a variable value.
16
 *
17
 * @package Mailcode
18
 * @subpackage Commands
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Commands_Command_ShowVariable extends Mailcode_Commands_Command implements Mailcode_Commands_Command_Type_Standalone
22
{
23
    use Mailcode_Traits_Commands_Validation_Variable;
24
25
    const VALIDATION_TOO_MANY_PARAMETERS = 69701;
26
27
    public function getName() : string
28
    {
29
        return 'showvar';
30
    }
31
    
32
    public function getLabel() : string
33
    {
34
        return t('Show variable');
35
    }
36
    
37
    public function supportsType(): bool
38
    {
39
        return false;
40
    }
41
    
42
    public function getDefaultType() : string
43
    {
44
        return '';
45
    }
46
47
    public function requiresParameters(): bool
48
    {
49
        return true;
50
    }
51
    
52
    public function supportsLogicKeywords() : bool
53
    {
54
        return false;
55
    }
56
    
57
    protected function getValidations() : array
58
    {
59
        return array(
60
            'variable',
61
            'no_other_tokens'
62
        );
63
    }
64
    
65
    public function generatesContent() : bool
66
    {
67
        return true;
68
    }
69
70
    protected function validateSyntax_no_other_tokens() : void
71
    {
72
        $tokens = $this->params->getInfo()->getTokens();
73
74
        if(count($tokens) > 1)
75
        {
76
            $this->validationResult->makeError(
77
                t('Unknown parameters found:').' '.
78
                t('Only the variable name should be specified.'),
79
                self::VALIDATION_TOO_MANY_PARAMETERS
80
            );
81
        }
82
    }
83
}
84