From 5cddbc44d81b21131bfcf2f675527e0ca07a4859 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 12:05:06 -0400 Subject: [PATCH] Updated BackgroundFill --- src/TgBotLib/Objects/BackgroundFill.php | 86 ++++++++++++------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/TgBotLib/Objects/BackgroundFill.php b/src/TgBotLib/Objects/BackgroundFill.php index 00d8506..fd20c92 100644 --- a/src/TgBotLib/Objects/BackgroundFill.php +++ b/src/TgBotLib/Objects/BackgroundFill.php @@ -1,54 +1,54 @@ type; - } + protected BackgroundFillType $type; - /** - * @inheritDoc - */ - public abstract function toArray(): array; - - /** - * @inheritDoc - */ - public static function fromArray(?array $data): ?BackgroundFill - { - if($data === null) + /** + * Type of the background fill + * + * @return BackgroundFillType + */ + public function getType(): BackgroundFillType { - return null; + return $this->type; } - if(!isset($data['type'])) - { - throw new InvalidArgumentException('BackgroundFill expected type'); - } + /** + * @inheritDoc + */ + public abstract function toArray(): array; - return match(BackgroundFillType::tryFrom($data['type'])) + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?BackgroundFill { - BackgroundFillType::SOLID => BackgroundFillSolid::fromArray($data), - BackgroundFillType::GRADIENT => BackgroundFillGradient::fromArray($data), - BackgroundFillType::FREEFORM_GRADIENT => BackgroundFillFreeformGradient::fromArray($data), - default => throw new InvalidArgumentException("Invalid BackgroundFill Type") - }; - } -} \ No newline at end of file + if($data === null) + { + return null; + } + + 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") + }; + } + } \ No newline at end of file