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

setURLEncoding()   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 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Traits_Commands_Validation_URLEncode} trait.
4
 *
5
 * @package Mailcode
6
 * @subpackage Validation
7
 * @see Mailcode_Traits_Commands_Validation_URLEncode
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
use Mailcode\Commands\ParamsException;
15
16
/**
17
 * Command validation drop-in: checks for the presence
18
 * of a "urlencode:" keyword, to automatically set the
19
 * command's URL encoding flag.
20
 *
21
 * @package Mailcode
22
 * @subpackage Validation
23
 * @author Sebastian Mordziol <[email protected]>
24
 *
25
 * @see Mailcode_Interfaces_Commands_Validation_URLEncode
26
 */
27
trait Mailcode_Traits_Commands_Validation_URLEncode
28
{
29
    public function getURLEncodeToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword
30
    {
31
        return $this->getEncodingToken(Mailcode_Commands_Keywords::TYPE_URLENCODE);
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

31
        return $this->/** @scrutinizer ignore-call */ getEncodingToken(Mailcode_Commands_Keywords::TYPE_URLENCODE);
Loading history...
32
    }
33
34
    public function isURLEncoded() : bool
35
    {
36
        return $this->getURLEncodeToken() !== null;
37
    }
38
39
    /**
40
     * @param bool $encoding
41
     * @return $this
42
     * @throws Mailcode_Exception
43
     */
44
    public function setURLEncoding(bool $encoding=true) : self
45
    {
46
        return $this->setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_URLENCODE, $encoding);
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

46
        return $this->/** @scrutinizer ignore-call */ setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_URLENCODE, $encoding);
Loading history...
47
    }
48
}
49