Passed
Push — master ( 75ee28...758f58 )
by Sebastian
04:00
created

  A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
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_ShowBase
22
{
23
    const VALIDATION_TOO_MANY_PARAMETERS = 69701;
24
25
    public function getName() : string
26
    {
27
        return 'showvar';
28
    }
29
    
30
    public function getLabel() : string
31
    {
32
        return t('Show variable');
33
    }
34
    
35
    protected function getValidations() : array
36
    {
37
        return array(
38
            'variable',
39
            'urlencode',
40
            'no_other_tokens'
41
        );
42
    }
43
    
44
    protected function validateSyntax_no_other_tokens() : void
45
    {
46
        $tokens = $this->params->getInfo()->getTokens();
47
48
        $count = 1;
49
50
        if(isset($this->urlencodeToken))
51
        {
52
            $count = 2;
53
        }
54
55
        if(count($tokens) > $count)
56
        {
57
            $this->validationResult->makeError(
58
                t('Unknown parameters found:').' '.
59
                t('Only the variable name should be specified.'),
60
                self::VALIDATION_TOO_MANY_PARAMETERS
61
            );
62
        }
63
    }
64
}
65