diff --git a/src/TgBotLib/Objects/PassportData.php b/src/TgBotLib/Objects/PassportData.php new file mode 100644 index 0000000..9928f43 --- /dev/null +++ b/src/TgBotLib/Objects/PassportData.php @@ -0,0 +1,74 @@ +data; + } + + /** + * Encrypted credentials required to decrypt the data + * + * @return EncryptedCredentials + */ + public function getCredentials(): EncryptedCredentials + { + return $this->credentials; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'data' => array_map(function (EncryptedPassportElement $element) + { + return $element->toArray(); + }, $this->data), + 'credentials' => $this->credentials->toArray(), + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + $object->data = array_map(function (array $element) + { + return EncryptedPassportElement::fromArray($element); + }, $data['data']); + $object->credentials = EncryptedCredentials::fromArray($data['credentials']); + + return $object; + } + } \ No newline at end of file