Conditions | 4 |
Paths | 5 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
20 | 7 | public function filterSingle($value, string $valueIdentifier = null) |
|
21 | { |
||
22 | // not a string, move along |
||
23 | 7 | if (! is_string($value)) { |
|
24 | 1 | return $value; |
|
25 | } |
||
26 | |||
27 | 6 | $len = strlen($value); |
|
28 | 6 | $start = $this->options[self::OPTION_START_CHARACTERS] ? |
|
29 | 3 | substr($value, 0, $this->options[self::OPTION_START_CHARACTERS]) : |
|
30 | 6 | ''; |
|
31 | 6 | $end = $this->options[self::OPTION_END_CHARACTERS] ? |
|
32 | 3 | substr($value, $len - $this->options[self::OPTION_END_CHARACTERS]) : |
|
33 | 6 | ''; |
|
34 | 6 | $middle = str_repeat( |
|
35 | 6 | $this->options[self::OPTION_REPLACEMENT_CHAR], |
|
36 | 6 | $len - $this->options[self::OPTION_START_CHARACTERS] - $this->options[self::OPTION_END_CHARACTERS] |
|
37 | ); |
||
38 | 6 | return $start . $middle . $end; |
|
39 | } |
||
40 | } |
||
41 |