Total Complexity | 9 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | class Mailcode_Translator_Syntax_ApacheVelocity_ElseIf extends Mailcode_Translator_Syntax_ApacheVelocity implements Mailcode_Translator_Command_ElseIf |
||
22 | { |
||
23 | public function translate(Mailcode_Commands_Command_ElseIf $command): string |
||
24 | { |
||
25 | if($command instanceof Mailcode_Commands_Command_ElseIf_Command) |
||
26 | { |
||
27 | return $this->translateCommand($command); |
||
28 | } |
||
29 | |||
30 | if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
||
31 | { |
||
32 | return $this->translateVariable($command); |
||
33 | } |
||
34 | |||
35 | if($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
||
36 | { |
||
37 | return $this->translateContains($command); |
||
38 | } |
||
39 | |||
40 | return ''; |
||
41 | } |
||
42 | |||
43 | protected function translateCommand(Mailcode_Commands_Command_ElseIf_Command $command) : string |
||
44 | { |
||
45 | $params = $command->getParams(); |
||
46 | |||
47 | if(!$params) |
||
|
|||
48 | { |
||
49 | return ''; |
||
50 | } |
||
51 | |||
52 | return sprintf( |
||
53 | '#elseif(%s)', |
||
54 | $params->getNormalized() |
||
55 | ); |
||
56 | } |
||
57 | |||
58 | protected function translateVariable(Mailcode_Commands_Command_ElseIf_Variable $command) : string |
||
65 | ); |
||
66 | } |
||
67 | |||
68 | protected function translateContains(Mailcode_Commands_Command_ElseIf_Contains $command) : string |
||
81 | ); |
||
82 | } |
||
83 | } |
||
84 |