type = $type instanceof SupportChannelType ? $type : SupportChannelType::from($type); $this->value = $this->type == SupportChannelType::EMAIL ? new Email($value) : new Url($value); } public function jsonSerialize(): array { return [ 'type' => $this->type, 'value' => $this->value ]; } }