trueValue = $trueValue; $this->falseValue = $falseValue; } /** * 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, 'convert']); } /** * Convert booleans to their user-defined values. * * @param list $sample */ public function convert(array &$sample) : void { foreach ($sample as &$value) { if (is_bool($value)) { $value = $value ? $this->trueValue : $this->falseValue; } } } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return "Boolean Converter (true value: {$this->trueValue}, false value: {$this->falseValue})"; } }