Passed
Push — master ( 466241...d4e985 )
by Sebastian
01:20 queued 15s
created

Mailcode_Parser_Statement_Tokenizer_Token_Variable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getNormalized() 0 3 1
A getVariable() 0 11 2
A hasSpacing() 0 3 1
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Parser_Statement_Tokenizer_Token_Variable} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Parser
7
 * @see Mailcode_Parser_Statement_Tokenizer_Token_Variable
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Token representing a variable name.
16
 *
17
 * @package Mailcode
18
 * @subpackage Parser
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Parser_Statement_Tokenizer_Token_Variable extends Mailcode_Parser_Statement_Tokenizer_Token
22
{
23
    public const ERROR_NOT_A_VARIABLE_INSTANCE = 49501;
24
25
    /**
26
     * @return Mailcode_Variables_Variable
27
     * @throws Mailcode_Parser_Exception
28
     */
29
    public function getVariable() : Mailcode_Variables_Variable
30
    {
31
        if($this->subject instanceof Mailcode_Variables_Variable)
32
        {
33
            return $this->subject;
34
        }
35
        
36
        throw new Mailcode_Parser_Exception(
37
            'Subject is not a variable instance.',
38
            null,
39
            self::ERROR_NOT_A_VARIABLE_INSTANCE
40
        );
41
    }
42
    
43
    public function getNormalized() : string
44
    {
45
        return $this->getVariable()->getFullName();
46
    }
47
48
    public function hasSpacing(): bool
49
    {
50
        return true;
51
    }
52
}
53