Passed
Push — master ( d06d8f...13736a )
by Sebastian
02:30
created

_translateElse()   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 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Translator_Syntax_ApacheVelocity} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Translator
7
 * @see Mailcode_Translator_Syntax_ApacheVelocity
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Allows translation mailcode to apache velocity syntax.
16
 *
17
 * @package Mailcode
18
 * @subpackage Translator
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Translator_Syntax_ApacheVelocity extends Mailcode_Translator_Syntax
22
{
23
    protected function _translateElseIf(Mailcode_Commands_Command_ElseIf $command): string
24
    {
25
        $params = $command->getParams();
26
        
27
        if($params)
0 ignored issues
show
introduced by
$params is of type Mailcode\Mailcode_Parser_Statement, thus it always evaluated to true.
Loading history...
28
        {
29
            return sprintf(
30
                '#elseif(%s)',
31
                $params->getNormalized()
32
            );
33
        }
34
        
35
        return '';
36
    }
37
38
    protected function _translateElse(Mailcode_Commands_Command_Else $command): string
39
    {
40
        return '#{else}';
41
    }
42
43
    protected function _translateIf(Mailcode_Commands_Command_If $command): string
44
    {
45
        $params = $command->getParams();
46
    
47
        if($params)
0 ignored issues
show
introduced by
$params is of type Mailcode\Mailcode_Parser_Statement, thus it always evaluated to true.
Loading history...
48
        {
49
            return sprintf(
50
                '#if(%s)',
51
                $params->getNormalized()
52
            );
53
        }
54
        
55
        return '';
56
    }
57
58
    protected function _translateShowVariable(Mailcode_Commands_Command_ShowVariable $command): string
59
    {
60
        return '${'.ltrim($command->getVariableName(), '$').'}';
61
    }
62
63
    protected function _translateFor(Mailcode_Commands_Command_For $command): string
64
    {
65
        $params = $command->getParams();
66
        
67
        if($params)
0 ignored issues
show
introduced by
$params is of type Mailcode\Mailcode_Parser_Statement, thus it always evaluated to true.
Loading history...
68
        {
69
            return sprintf(
70
                '#for(%s)',
71
                $params->getNormalized()
72
            );
73
        }
74
        
75
        return '';
76
    }
77
78
    protected function _translateSetVariable(Mailcode_Commands_Command_SetVariable $command): string
79
    {
80
        $params = $command->getParams();
81
        
82
        if($params)
0 ignored issues
show
introduced by
$params is of type Mailcode\Mailcode_Parser_Statement, thus it always evaluated to true.
Loading history...
83
        {
84
            return sprintf(
85
                '#set(%s)',
86
                $params->getNormalized()
87
            );
88
        }
89
        
90
        return '';
91
    }
92
93
    protected function _translateEnd(Mailcode_Commands_Command_End $command): string
94
    {
95
        return '#{end}';
96
    }
97
}
98