Passed
Push — master ( 77f2a3...0c35c3 )
by Sebastian
03:02
created

translateNotContains()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Translator_Syntax_ApacheVelocity_ElseIf} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Translator
7
 * @see Mailcode_Translator_Syntax_ApacheVelocity_ElseIf
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Translates the "ElseIf" command to Apache Velocity.
16
 *
17
 * @package Mailcode
18
 * @subpackage Translator
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Translator_Syntax_ApacheVelocity_ElseIf extends Mailcode_Translator_Syntax_ApacheVelocity_Base_AbstractIf implements Mailcode_Translator_Command_ElseIf
22
{
23
    protected function getCommandTemplate() : string
24
    {
25
        return '#elseif(%s)';
26
    }
27
    
28
    public function translate(Mailcode_Commands_Command_ElseIf $command): string
29
    {
30
        return $this->_translate($command);
31
    }
32
    
33
    protected function translateBeginsWith(Mailcode_Commands_Command_ElseIf_BeginsWith $command) : string
34
    {
35
        return $this->_translateSearch(
36
            'starts',
37
            $command->getVariable(),
38
            $command->isCaseInsensitive(),
39
            $command->getSearchTerm()
40
        );
41
    }
42
    
43
    protected function translateEndsWith(Mailcode_Commands_Command_ElseIf_EndsWith $command) : string
44
    {
45
        return $this->_translateSearch(
46
            'ends',
47
            $command->getVariable(),
48
            $command->isCaseInsensitive(),
49
            $command->getSearchTerm()
50
        );
51
    }
52
53
    protected function translateBiggerThan(Mailcode_Commands_Command_ElseIf_BiggerThan $command) : string
54
    {
55
        return $this->_translateNumberComparison(
56
            $command->getVariable(),
57
            $command->getNumber(),
58
            '>'
59
        );
60
    }
61
62
    protected function translateSmallerThan(Mailcode_Commands_Command_ElseIf_SmallerThan $command) : string
63
    {
64
        return $this->_translateNumberComparison(
65
            $command->getVariable(),
66
            $command->getNumber(),
67
            '<'
68
        );
69
    }
70
71
    protected function translateEqualsNumber(Mailcode_Commands_Command_ElseIf_EqualsNumber $command) : string
72
    {
73
        return $this->_translateNumberComparison(
74
            $command->getVariable(),
75
            $command->getNumber(),
76
            '=='
77
        );
78
    }
79
80
    protected function translateCommand(Mailcode_Commands_Command_ElseIf_Command $command) : string
81
    {
82
        return $this->_translateGeneric($command);
83
    }
84
    
85
    protected function translateVariable(Mailcode_Commands_Command_ElseIf_Variable $command) : string
86
    {
87
        return $this->_translateVariable(
88
            $command->getVariable(),
89
            $command->getSign(),
90
            $command->getValue()
91
        );
92
    }
93
    
94
    protected function translateContains(Mailcode_Commands_Command_ElseIf_Contains $command) : string
95
    {
96
        return $this->_translateContains(
97
            $command->getVariable(),
98
            $command->isCaseInsensitive(),
99
            $command->getSearchTerms(),
100
            $command->getType()
101
        );
102
    }
103
104
    protected function translateNotContains(Mailcode_Commands_Command_ElseIf_NotContains $command) : string
105
    {
106
        return $this->_translateContains(
107
            $command->getVariable(),
108
            $command->isCaseInsensitive(),
109
            $command->getSearchTerms(),
110
            $command->getType()
111
        );
112
    }
113
    
114
    protected function translateEmpty(Mailcode_Commands_Command_ElseIf_Empty $command) : string
115
    {
116
        return $this->_translateEmpty($command->getVariable(), false);
117
    }
118
119
    protected function translateNotEmpty(Mailcode_Commands_Command_ElseIf_NotEmpty $command) : string
120
    {
121
        return $this->_translateEmpty($command->getVariable(), true);
122
    }
123
}
124