args = $args; } public function setType(array $targetTypes): self{ $this->targetTypes = $targetTypes; $converterType = $this->converterType; $this->converter = new $converterType($targetTypes, ...$this->args); return $this; } public function convertFrom(string|array|int|float|bool|null $raw, string $name): mixed { if($this->converter === null){ throw new \Exception("converter[{$name}] is not set"); } return $this->converter->convertFrom($raw, $name); } public function convertTo(mixed $target): string|array|int|float|bool|null { if($this->converter === null){ throw new \Exception('converter is not set'); } return $this->converter->convertTo($target); } }