From 17ceeeda5a7ce133da2bd84083e1407581833a5b Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 12:29:19 -0400 Subject: [PATCH] Added Birthdate --- src/TgBotLib/Objects/Birthdate.php | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/TgBotLib/Objects/Birthdate.php diff --git a/src/TgBotLib/Objects/Birthdate.php b/src/TgBotLib/Objects/Birthdate.php new file mode 100644 index 0000000..d35a6ed --- /dev/null +++ b/src/TgBotLib/Objects/Birthdate.php @@ -0,0 +1,72 @@ +day; + } + + /** + * Month of the user's birth; 1-12 + * + * @return int + */ + public function getMonth(): int + { + return $this->month; + } + + /** + * Optional. Year of the user's birth + * + * @return int|null + */ + public function getYear(): ?int + { + return $this->year; + } + + /** + * @inheritDoc + */ + public function toArray(): ?array + { + return [ + 'day' => $this->day, + 'month' => $this->month, + 'year' => $this->year, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?Birthdate + { + if($data === null) + { + return null; + } + + $object = new self(); + $object->day = $data['day']; + $object->month = $data['month']; + $object->year = $data['year'] ?? null; + + return $object; + } + } \ No newline at end of file