Passed
Push — master ( 75ee28...758f58 )
by Sebastian
04:00
created

Mailcode_Traits_Commands_Validation_URLEncode   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getURLEncodeToken() 0 3 1
A validateSyntax_urlencode() 0 13 3
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
/**
15
 * Command validation drop-in: checks for the presence
16
 * of a "urlencode:" keyword, to automatically set the
17
 * command's URL encoding flag.
18
 *
19
 * @package Mailcode
20
 * @subpackage Validation
21
 * @author Sebastian Mordziol <[email protected]>
22
 *
23
 * @property Mailcode_Parser_Statement_Validator $validator
24
 * @property Mailcode_Parser_Statement $params
25
 */
26
trait Mailcode_Traits_Commands_Validation_URLEncode
27
{
28
    /**
29
     * @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL
30
     */
31
    protected $urlencodeToken;
32
33
    protected function validateSyntax_urlencode() : void
34
    {
35
        $keywords = $this->params->getInfo()->getKeywords();
36
37
        foreach($keywords as $keyword)
38
        {
39
            if($keyword->isURLEncoded())
40
            {
41
                $this->urlencodeToken = $keyword;
42
43
                $this->setURLEncoding(true);
0 ignored issues
show
Bug introduced by
It seems like setURLEncoding() 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

43
                $this->/** @scrutinizer ignore-call */ 
44
                       setURLEncoding(true);
Loading history...
44
45
                break;
46
            }
47
        }
48
    }
49
50
    public function getURLEncodeToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword
51
    {
52
        return $this->urlencodeToken;
53
    }
54
}
55