Total Complexity | 5 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 76.92% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class StringNormalizer extends AbstractNormalizer |
||
12 | { |
||
13 | private bool $trim = true; |
||
14 | private array $trimChars = [' ', "\t", "\n", "\r", "\0", "\x0B"]; |
||
15 | |||
16 | /** |
||
17 | * Sets whether the string should be trimmed. Defaults to true. |
||
18 | */ |
||
19 | 2 | public function trim(bool $trim): self |
|
20 | { |
||
21 | 2 | $this->trim = $trim; |
|
22 | |||
23 | 2 | return $this; |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * Sets the character mask passed to trim(). Defaults to the mask used by trim itself. |
||
28 | */ |
||
29 | public function trimChars(array $trimChars): self |
||
30 | { |
||
31 | $this->trimChars = $trimChars; |
||
32 | |||
33 | return $this; |
||
34 | } |
||
35 | |||
36 | 2 | public function addTrimChar(string $char): self |
|
41 | } |
||
42 | |||
43 | 4 | protected function getNormalizedValue(string $value): string |
|
50 | } |
||
51 | } |
||
52 |