Passed
Push — master ( 7c0b30...83b5cd )
by Sebastian
02:33
created

getCaseToken()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 8
rs 10
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Traits_Commands_Validation_Variable} trait.
4
 *
5
 * @package Mailcode
6
 * @subpackage Validation
7
 * @see Mailcode_Traits_Commands_Validation_Variable
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Command validation drop-in: checks for the presence
16
 * of the `insensitive:` keyword in the command statement,
17
 * and sets the case insensitive flag accordingly.
18
 *
19
 * @package Mailcode
20
 * @subpackage Validation
21
 * @author Sebastian Mordziol <[email protected]>
22
 *
23
 * @property Mailcode_Parser_Statement_Validator $validator
24
 */
25
trait Mailcode_Traits_Commands_Validation_CaseSensitive
26
{
27
   /**
28
    * @var boolean
29
    */
30
    protected $caseInsensitive = false;
31
32
   /**
33
    * @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL
34
    */
35
    protected $caseToken;
36
    
37
    protected function validateSyntax_case_sensitive() : void
38
    {
39
        $val = $this->validator->createKeyword('insensitive');
40
        
41
        $this->caseInsensitive = $val->isValid();
42
        
43
        if($val->isValid())
44
        {
45
            $this->caseToken = $val->getToken();
46
        }
47
    }
48
    
49
    public function isCaseInsensitive() : bool
50
    {
51
        return $this->caseInsensitive;
52
    }
53
    
54
    public function getCaseToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword
55
    {
56
        if($this->caseToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
57
        {
58
            return $this->caseToken;
59
        }
60
        
61
        return null;
62
    }
63
}
64