normalize = $uppercase ? 'strtoupper' : 'strtolower'; } /** * Return the data types that this transformer is compatible with. * * @internal * * @return list */ public function compatibility() : array { return DataType::all(); } /** * Transform the dataset in place. * * @param array $samples */ public function transform(array &$samples) : void { array_walk($samples, [$this, 'normalize']); } /** * Normalize the text in a sample. * * @param list $sample */ public function normalize(array &$sample) : void { foreach ($sample as &$value) { if (is_string($value)) { $value = call_user_func($this->normalize, $value); } } } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return 'Text Normalizer'; } }