Blame view
app/Support/Utils/EmailObfuscator.php
625 Bytes
e77200db5 Initial commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<?php namespace FootyRoom\Support\Utils; class EmailObfuscator { /** * Obfuscates given email address. * * @param string $email * * @return string */ public static function obfuscate($email) { $chars = str_split($email); $hiddenEmail = []; for ($i = 0; $i < count($chars); $i++) { if ($i < 1 || $i+5 >= count($chars) || $chars[$i+1] == '@' || $chars[$i] == '@') { $hiddenEmail[] = $chars[$i]; } else { $hiddenEmail[] = '*'; } } return implode('', $hiddenEmail); } } |