Total Complexity | 7 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 58.81% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class StringNormalizer extends AbstractNormalizer |
||
10 | { |
||
11 | /** @var bool */ |
||
12 | private $trim = true; |
||
13 | /** @var array */ |
||
14 | private $trimChars = [' ', "\t", "\n", "\r", "\0", "\x0B"]; |
||
15 | |||
16 | /** |
||
17 | * Sets whether the string should be trimmed. Defaults to true. |
||
18 | */ |
||
19 | 2 | public function setTrim(bool $trim): self |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * Sets the character mask passed to trim(). Defaults to the mask used by trim itself. |
||
28 | */ |
||
29 | public function setTrimChars(array $trimChars): self |
||
30 | { |
||
31 | $this->trimChars = $trimChars; |
||
32 | |||
33 | return $this; |
||
34 | } |
||
35 | |||
36 | 2 | public function addTrimChar(string $char): self |
|
37 | { |
||
38 | 2 | $this->trimChars[] = $char; |
|
39 | |||
40 | 2 | return $this; |
|
41 | } |
||
42 | |||
43 | public function getTrimChars(): array |
||
44 | { |
||
45 | return $this->trimChars; |
||
46 | } |
||
47 | |||
48 | public function shouldTrim(): bool |
||
49 | { |
||
50 | return $this->trim; |
||
51 | } |
||
52 | |||
53 | 4 | protected function getNormalizedValue(string $value): string |
|
60 | } |
||
61 | } |
||
62 |