| Conditions | 7 |
| Paths | 8 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public static function obfuscate($string, $start = 0, $end = 3, $replacement = '*'): string |
||
| 25 | { |
||
| 26 | $len = \strlen($string); |
||
| 27 | |||
| 28 | if ($start < 0) { |
||
| 29 | $start += $len; |
||
| 30 | } |
||
| 31 | $start = min($start, $len - 1); |
||
| 32 | |||
| 33 | if ($end < 0) { |
||
| 34 | $end += $len; |
||
| 35 | } |
||
| 36 | $end = min($end, $len - 1); |
||
| 37 | |||
| 38 | if (0 === $len || $len === $start + 1 || $len === $end + 1 || $len <= $start + $end) { |
||
| 39 | return $string; |
||
| 40 | } |
||
| 41 | |||
| 42 | return substr($string, 0, $start).str_repeat($replacement, $len - $end - $start).substr($string, $len - $end, $end); |
||
| 43 | } |
||
| 45 |