Test Failed
Push — master ( 9ff364...742ef2 )
by Sebastian
03:58
created

IDNDecodeTrait::getIDNDecodingToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * File containing the trait {@see \Mailcode\Traits\Commands\Validation\IDNDecodeTrait}.
4
 *
5
 * @package Mailcode
6
 * @subpackage Validation
7
 * @see \Mailcode\Traits\Commands\Validation\IDNDecodeTrait
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode\Traits\Commands\Validation;
13
14
use Mailcode\Interfaces\Commands\Validation\IDNDecodeInterface;
15
use Mailcode\Mailcode_Commands_Keywords;
16
use Mailcode\Mailcode_Exception;
17
use Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Keyword;
18
19
/**
20
 * Command validation drop-in: checks for the presence
21
 * of the `idndecode:` keyword in the command statement,
22
 * and sets the IDN decode enabled flag accordingly.
23
 *
24
 * @package Mailcode
25
 * @subpackage Validation
26
 * @author Sebastian Mordziol <[email protected]>
27
 *
28
 * @see IDNDecodeInterface
29
 */
30
trait IDNDecodeTrait
31
{
32
    /**
33
     * @param bool $enabled
34
     * @return $this
35
     */
36
    public function setIDNDecodingEnabled(bool $enabled) : self
37
    {
38
        return $this->setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_IDN_DECODE, $enabled);
0 ignored issues
show
Bug introduced by
It seems like setEncodingEnabled() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        return $this->/** @scrutinizer ignore-call */ setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_IDN_DECODE, $enabled);
Loading history...
39
    }
40
41
    public function isIDNDecoded() : bool
42
    {
43
        return $this->getIDNDecodingToken() !== null;
44
    }
45
46
    public function getIDNDecodingToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword
47
    {
48
        return $this->getEncodingToken(Mailcode_Commands_Keywords::TYPE_IDN_DECODE);
0 ignored issues
show
Bug introduced by
It seems like getEncodingToken() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
        return $this->/** @scrutinizer ignore-call */ getEncodingToken(Mailcode_Commands_Keywords::TYPE_IDN_DECODE);
Loading history...
49
    }
50
}
51