public function NumberAnonymizer::anonymize in General Data Protection Regulation 8.2
Same name and namespace in other branches
- 8 modules/anonymizer/src/Plugin/Anonymizer/NumberAnonymizer.php \Drupal\anonymizer\Plugin\Anonymizer\NumberAnonymizer::anonymize()
- 3.0.x modules/anonymizer/src/Plugin/Anonymizer/NumberAnonymizer.php \Drupal\anonymizer\Plugin\Anonymizer\NumberAnonymizer::anonymize()
Throws
\RuntimeException
Overrides AnonymizerInterface::anonymize
File
- modules/
anonymizer/ src/ Plugin/ Anonymizer/ NumberAnonymizer.php, line 28
Class
- NumberAnonymizer
- Class NumberAnonymizer.
Namespace
Drupal\anonymizer\Plugin\AnonymizerCode
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;
}