NumberAnonymizer.php in General Data Protection Regulation 8
File
modules/anonymizer/src/Plugin/Anonymizer/NumberAnonymizer.php
View source
<?php
namespace Drupal\anonymizer\Plugin\Anonymizer;
use Drupal\anonymizer\Anonymizer\AnonymizerBase;
use Drupal\Core\Field\FieldItemListInterface;
class NumberAnonymizer extends AnonymizerBase {
public function anonymize($input, FieldItemListInterface $field = NULL) {
if ($length = \strlen($input)) {
$generator = $this->faker
->generator();
$length = $generator
->numberBetween(1, $length);
return $generator
->numerify(\str_repeat('#', $length));
}
return $input;
}
}