Passed
Push — master ( 77b992...62880d )
by Sebastian
02:14
created

Mailcode_Commands_Command_ShowVariable   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 14
c 3
b 0
f 0
dl 0
loc 48
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getLabel() 0 3 1
A getName() 0 3 1
A getValidations() 0 3 1
A supportsType() 0 3 1
A validateSyntax_require_variable() 0 12 2
A generatesContent() 0 3 1
A requiresParameters() 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
22
{
23
    // TODO needs real code
24
    const VALIDATION_VARIABLE_COUNT_MISMATCH = 112001;
25
    
26
    public function getName() : string
27
    {
28
        return 'showvar';
29
    }
30
    
31
    public function getLabel() : string
32
    {
33
        return t('Show variable');
34
    }
35
    
36
    public function supportsType(): bool
37
    {
38
        return false;
39
    }
40
41
    public function requiresParameters(): bool
42
    {
43
        return true;
44
    }
45
46
    protected function validateSyntax_require_variable()
47
    {
48
         $amount = $this->getVariables()->countVariables();
49
         
50
         if($amount === 1)
51
         {
52
             return;
53
         }
54
         
55
         $this->validationResult->makeError(
56
            t('Command has %1$s variables, %2$s expected.', $amount, 1),
57
            self::VALIDATION_VARIABLE_COUNT_MISMATCH
58
         );
59
    }
60
    
61
    protected function getValidations() : array
62
    {
63
        return array('require_variable');
64
    }
65
    
66
    public function generatesContent() : bool
67
    {
68
        return true;
69
    }
70
}
71