Passed
Push — master ( 95d9aa...1515ff )
by Sebastian
05:04 queued 13s
created

Mailcode_Parser_Match::removeNonBreakingSpaces()   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_Parser} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Parser
7
 * @see Mailcode_Parser
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Mailcode parser match, container for a command found
16
 * while parsing a string.
17
 *
18
 * @package Mailcode
19
 * @subpackage Parser
20
 * @author Sebastian Mordziol <[email protected]>
21
 */
22
class Mailcode_Parser_Match
23
{
24
   /**
25
    * @var string
26
    */
27
    protected $name;
28
    
29
   /**
30
    * @var string
31
    */
32
    protected $type;
33
    
34
   /**
35
    * @var string
36
    */
37
    protected $params;
38
    
39
   /**
40
    * @var string
41
    */
42
    protected $matchedString;
43
    
44
    public function __construct(string $name, string $type, string $params, string $matchedString)
45
    {
46
        $this->name = strtolower($name);
47
        $this->type = strtolower($type);
48
        $this->params = trim($params);
49
        $this->matchedString = $matchedString;
50
        
51
        $this->applyFilters();
52
    }
53
    
54
    public function getName() : string
55
    {
56
        return $this->name;
57
    }
58
    
59
    public function getType() : string
60
    {
61
        return $this->type;
62
    }
63
    
64
    public function getParams() : string
65
    {
66
        return $this->params;
67
    }
68
    
69
    public function getMatchedString() : string
70
    {
71
        return $this->matchedString;
72
    }
73
    
74
    private function applyFilters() : void
75
    {
76
        $this->params = $this->removeNonBreakingSpaces($this->params);
77
    }
78
    
79
    private function removeNonBreakingSpaces(string $subject) : string
80
    {
81
        return str_replace(array('&nbsp;', '&#160;'), ' ', $subject);
82
    }
83
}
84