Skip to content

Commit

Permalink
Merge pull request #21 from PayU/fallback_feature
Browse files Browse the repository at this point in the history
fallback option when email is not email
  • Loading branch information
alexconrad authored Sep 14, 2022
2 parents 69ee81e + 6eb1918 commit b7b93f4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ValueAnonymizers/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use PayU\MysqlDumpAnonymizer\Entity\AnonymizedValue;
use PayU\MysqlDumpAnonymizer\Entity\Value;
use PayU\MysqlDumpAnonymizer\AnonymizationProvider\ValueAnonymizerInterface;
use PayU\MysqlDumpAnonymizer\ValueAnonymizers\HashService\HashAnonymizer;
use PayU\MysqlDumpAnonymizer\ValueAnonymizers\HashService\StringHashInterface;
use PayU\MysqlDumpAnonymizer\ValueAnonymizers\HashService\StringHashSha256;

final class Email implements ValueAnonymizerInterface
{
Expand All @@ -27,6 +29,10 @@ public function anonymize(Value $value, array $row): AnonymizedValue

$string = $value->getUnEscapedValue();

if (mb_strpos($string, '@') === false) {
return (new FreeText(new StringHashSha256(new HashAnonymizer())))->anonymize($value, $row);
}

[$user, $domain] = explode('@', $string, 2);

if (strlen($user) < 10) {
Expand Down

0 comments on commit b7b93f4

Please sign in to comment.