type; } /** * @inheritDoc */ public abstract function toArray(): array; /** * @inheritDoc */ public static function fromArray(array $data): BackgroundFill { if(!isset($data['type'])) { throw new InvalidArgumentException('BackgroundFill expected type'); } return match(BackgroundFillType::tryFrom($data['type'])) { BackgroundFillType::SOLID => BackgroundFillSolid::fromArray($data), BackgroundFillType::GRADIENT => BackgroundFillGradient::fromArray($data), BackgroundFillType::FREEFORM_GRADIENT => BackgroundFillFreeformGradient::fromArray($data), default => throw new InvalidArgumentException("Invalid BackgroundFill Type") }; } }