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 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 15
c 1
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_If::translateBeginsWith() 0 7 1
A Mailcode_Translator_Syntax_ApacheVelocity_If::translateEndsWith() 0 7 1
A Mailcode_Translator_Syntax_ApacheVelocity_If::translateVariable() 0 6 1
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Translator_Syntax_ApacheVelocity_If} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Translator
7
 * @see Mailcode_Translator_Syntax_ApacheVelocity_If
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Translates the "If" command to Apache Velocity.
16
 *
17
 * @package Mailcode
18
 * @subpackage Translator
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Translator_Syntax_ApacheVelocity_If extends Mailcode_Translator_Syntax_ApacheVelocity_Base_AbstractIf implements Mailcode_Translator_Command_If
22
{
23
    protected function getCommandTemplate() : string
24
    {
25
        return '#if(%s)';
26
    }
27
    
28
    public function translate(Mailcode_Commands_Command_If $command): string
29
    {
30
        return $this->_translate($command);
31
    }
32
33
    protected function translateCommand(Mailcode_Commands_Command_If_Command $command) : string
34
    {
35
        return $this->_translateGeneric($command);
36
    }
37
    
38
    protected function translateBeginsWith(Mailcode_Commands_Command_If_BeginsWith $command) : string
39
    {
40
        return $this->_translateSearch(
41
            'starts',
42
            $command->getVariable(),
43
            $command->isCaseInsensitive(),
44
            $command->getSearchTerm()
45
        );
46
    }
47
    
48
    protected function translateEndsWith(Mailcode_Commands_Command_If_EndsWith $command) : string
49
    {
50
        return $this->_translateSearch(
51
            'ends',
52
            $command->getVariable(),
53
            $command->isCaseInsensitive(),
54
            $command->getSearchTerm()
55
        );
56
    }
57
    
58
    protected function translateVariable(Mailcode_Commands_Command_If_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_If_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_If_Empty $command) : string
77
    {
78
        return $this->_translateEmpty($command->getVariable(), false);
79
    }
80
    
81
    protected function translateNotEmpty(Mailcode_Commands_Command_If_NotEmpty $command) : string
82
    {
83
        return $this->_translateEmpty($command->getVariable(), true);
84
    }
85
}
86