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

getValidations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
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_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