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

Mailcode_Traits_Commands_Validation_URLEncode   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 1
Metric Value
eloc 4
c 5
b 0
f 1
dl 0
loc 20
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getURLEncodeToken() 0 3 1
A setURLEncoding() 0 3 1
A isURLEncoded() 0 3 1
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