$this->name(), 'description' => $this->description(), 'types' => $this->types(), ]); } /** * Mount the type definition string. * * @return string */ public function mount(): string { return Str::of('union ') ->append($this->name()) ->append(' = ') ->append(implode(' | ', Arr::map($this->types(), fn (BaseType $type) => $type->name()))) ->append("\n") ->__toString(); } /** * The name of the union type. * * @return string */ public function name(): string { return Str::of(class_basename($this)) ->__toString(); } /** * The description of the union type. * * @return string */ public function description(): string { return ''; } /** * The types that this union can resolve to. * * @return array */ abstract public function types(): array; }