From 18ba52b3765960a834e41bb6393b2ac90dec8696 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 13:03:29 -0400 Subject: [PATCH] Added BusinessOpeningHours --- src/TgBotLib/Objects/BusinessOpeningHours.php | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/TgBotLib/Objects/BusinessOpeningHours.php diff --git a/src/TgBotLib/Objects/BusinessOpeningHours.php b/src/TgBotLib/Objects/BusinessOpeningHours.php new file mode 100644 index 0000000..12809bd --- /dev/null +++ b/src/TgBotLib/Objects/BusinessOpeningHours.php @@ -0,0 +1,62 @@ +time_zone_name; + } + + /** + * List of time intervals describing business opening hours + * + * @return BusinessOpeningHoursInterval[]|null + */ + public function getOpeningHours(): ?array + { + return $this->opening_hours; + } + + /** + * @inheritDoc + */ + public function toArray(): ?array + { + return [ + 'time_zone_name' => $this->time_zone_name, + 'opening_hours' => array_map(fn(BusinessOpeningHoursInterval $item) => $item->toArray(), $this->opening_hours) + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?BusinessOpeningHours + { + if($data === null) + { + return null; + } + + $object = new self(); + $object->time_zone_name = $data['time_zone_name']; + $object->opening_hours = array_map(fn($item) => BusinessOpeningHoursInterval::fromArray($item), $data['opening_hours']); + + return $object; + } + } \ No newline at end of file