Passed
Push — master ( 2e2cc3...b09f9f )
by Sebastian
04:26
created

translate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 14
rs 10
1
<?php
2
/**
3
 * File containing the {@see \Mailcode\Mailcode_Translator_Syntax_ApacheVelocity_ShowPhone} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Translator
7
 * @see \Mailcode\Mailcode_Translator_Syntax_ApacheVelocity_ShowPhone
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Translates the "ShowNumber" command to Apache Velocity.
16
 *
17
 * @package Mailcode
18
 * @subpackage Translator
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Translator_Syntax_ApacheVelocity_ShowPhone extends Mailcode_Translator_Syntax_ApacheVelocity implements Mailcode_Translator_Command_ShowPhone
22
{
23
    public function translate(Mailcode_Commands_Command_ShowPhone $command): string
24
    {
25
        $template = "phone.e164(%s, '%s')";
26
27
        $varName = ltrim($command->getVariableName(), '$');
28
        $format = $command->getSourceFormat();
29
30
        $statement = sprintf(
31
            $template,
32
            '$'.$varName,
33
            $format
34
        );
35
36
        return $this->addURLEncoding($command, $statement);
37
    }
38
}
39