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

validateSyntax_no_other_tokens()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 10
rs 10
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