Passed
Push — master ( d8dc61...dfdb64 )
by Sebastian
09:05
created

EndTranslation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
c 0
b 0
f 0
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A translate() 0 10 2
1
<?php
2
/**
3
 * @package Mailcode
4
 * @subpackage Translator
5
 */
6
7
declare(strict_types=1);
8
9
namespace Mailcode\Translator\Syntax\ApacheVelocity;
10
11
use Mailcode\Mailcode_Commands_Command_End;
12
use Mailcode\Mailcode_Interfaces_Commands_PreProcessing;
13
use Mailcode\Mailcode_Translator_Command_End;
14
use Mailcode\Translator\Syntax\ApacheVelocity;
15
16
/**
17
 * Translates the {@see Mailcode_Commands_Command_End} command to Apache Velocity.
18
 *
19
 * @package Mailcode
20
 * @subpackage Translator
21
 * @author Sebastian Mordziol <[email protected]>
22
 */
23
class EndTranslation extends ApacheVelocity implements Mailcode_Translator_Command_End
24
{
25
    public function translate(Mailcode_Commands_Command_End $command): string
26
    {
27
        // This ending command is tied to a preprocessing command: Since
28
        // we do not want to keep these, we return an empty string to strip
29
        // it out.
30
        if($command->getOpeningCommand() instanceof Mailcode_Interfaces_Commands_PreProcessing) {
31
            return '';
32
        }
33
34
        return '#{end}';
35
    }
36
}
37