Passed
Push — master ( 2147dc...8d3817 )
by Sebastian
03:06 queued 11s
created

translateBody()   B

Complexity

Conditions 8
Paths 8

Size

Total Lines 38
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 15
c 0
b 0
f 0
nc 8
nop 1
dl 0
loc 38
rs 8.4444

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Mailcode_Translator_Syntax_ApacheVelocity_ElseIf::translateVariable() 0 6 1
A Mailcode_Translator_Syntax_ApacheVelocity_ElseIf::translateEndsWith() 0 7 1
A Mailcode_Translator_Syntax_ApacheVelocity_ElseIf::translateCommand() 0 3 1
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 translateCommand(Mailcode_Commands_Command_ElseIf_Command $command) : string
54
    {
55
        return $this->_translateGeneric($command);
56
    }
57
    
58
    protected function translateVariable(Mailcode_Commands_Command_ElseIf_Variable $command) : string
59
    {
60
        return $this->_translateVariable(
61
            $command->getVariable(),
62
            $command->getSign(),
63
            $command->getValue()
64
        );
65
    }
66
    
67
    protected function translateContains(Mailcode_Commands_Command_ElseIf_Contains $command) : string
68
    {
69
        return $this->_translateContains(
70
            $command->getVariable(),
71
            $command->isCaseInsensitive(),
72
            $command->getSearchTerms()
73
        );
74
    }
75
    
76
    protected function translateEmpty(Mailcode_Commands_Command_ElseIf_Empty $command) : string
77
    {
78
        return $this->_translateEmpty($command->getVariable(), false);
79
    }
80
81
    protected function translateNotEmpty(Mailcode_Commands_Command_ElseIf_NotEmpty $command) : string
82
    {
83
        return $this->_translateEmpty($command->getVariable(), true);
84
    }
85
}
86