Test Failed
Push — master ( f51294...9c5f94 )
by Sebastian
03:08
created

supportsLogicKeywords()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Commands_Command_For} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Commands
7
 * @see Mailcode_Commands_Command_For
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Mailcode command: opening FOR statement.
16
 *
17
 * @package Mailcode
18
 * @subpackage Commands
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Commands_Command_For extends Mailcode_Commands_Command implements Mailcode_Commands_Command_Type_Opening
22
{
23
    const VALIDATION_INVALID_FOR_STATEMENT = 49701;
24
    
25
    public function getName() : string
26
    {
27
        return 'for';
28
    }
29
    
30
    public function getLabel() : string
31
    {
32
        return t('FOR loop');
33
    }
34
    
35
    public function supportsType(): bool
36
    {
37
        return false;
38
    }
39
    
40
    public function getDefaultType() : string
41
    {
42
        return '';
43
    }
44
    
45
    public function requiresParameters(): bool
46
    {
47
        return true;
48
    }
49
    
50
    public function supportsLogicKeywords() : bool
51
    {
52
        return false;
53
    }
54
    
55
    protected function getValidations() : array
56
    {
57
        return array(
58
            'statement'
59
        );
60
    }
61
    
62
    public function generatesContent() : bool
63
    {
64
        return false;
65
    }
66
    
67
    protected function validateSyntax_statement() : void
68
    {
69
        $info = $this->params->getInfo();
70
        
71
        $variable = $info->getVariableByIndex(0);
72
        $keyword = $info->getKeywordByIndex(1);
73
        $container = $info->getVariableByIndex(2);
74
        
75
        if($variable && $keyword && $container && $keyword->isForIn())
76
        {
77
            return;
78
        }
79
        
80
        $this->validationResult->makeError(
81
            t('Not a valid for loop.').' '.t('Is the %1$s keyword missing?', 'in:'),
82
            self::VALIDATION_INVALID_FOR_STATEMENT
83
        );
84
    }
85
}
86