Passed
Push — master ( 8482a1...034aeb )
by Sebastian
15:02
created

BaseCommandTranslation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * File containing the {@see \Mailcode\Translator\BaseCommandTranslation} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Translator
7
 * @see \Mailcode\Translator\BaseCommandTranslation
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode\Translator;
13
14
use Mailcode\Interfaces\Commands\EncodableInterface;
15
use Mailcode\Mailcode_Commands_Command;
16
17
/**
18
 * Abstract base class for syntax command translators.
19
 *
20
 * @package Mailcode
21
 * @subpackage Translator
22
 * @author Sebastian Mordziol <[email protected]>
23
 * 
24
 * @method string translate(Mailcode_Commands_Command $command)
25
 */
26
abstract class BaseCommandTranslation
27
{
28
    private SyntaxInterface $syntax;
29
30
    public function getLabel() : string
31
    {
32
        return $this->syntax->getLabel();
33
    }
34
35
    public function getSyntaxName() : string
36
    {
37
        return $this->syntax->getTypeID();
38
    }
39
40
    public function __construct(SyntaxInterface $syntax)
41
    {
42
        $this->syntax = $syntax;
43
    }
44
45
    protected function hasVariableEncodings(Mailcode_Commands_Command $command) : bool
46
    {
47
        return $command instanceof EncodableInterface && $command->hasActiveEncodings();
48
    }
49
}
50