Updated PaidMedia objects
This commit is contained in:
parent
2405873510
commit
46d6cdf124
4 changed files with 24 additions and 7 deletions
|
@ -31,8 +31,13 @@ abstract class PaidMedia implements ObjectTypeInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): PaidMedia
|
||||
public static function fromArray(?array $data): ?PaidMedia
|
||||
{
|
||||
if($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!isset($data['type']))
|
||||
{
|
||||
throw new InvalidArgumentException('Paid media type is required');
|
||||
|
|
|
@ -48,10 +48,14 @@ class PaidMediaPhoto extends PaidMedia implements ObjectTypeInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): PaidMediaPhoto
|
||||
public static function fromArray(?array $data): ?PaidMediaPhoto
|
||||
{
|
||||
$object = new self();
|
||||
if($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$object = new self();
|
||||
$object->type = PaidMediaType::PHOTO;
|
||||
$object->photo = array_map(fn(array $photo) => PhotoSize::fromArray($photo), $data['photo']);
|
||||
|
||||
|
|
|
@ -58,10 +58,14 @@ class PaidMediaPreview extends PaidMedia implements ObjectTypeInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): PaidMediaPreview
|
||||
public static function fromArray(?array $data): ?PaidMediaPreview
|
||||
{
|
||||
$object = new self();
|
||||
if($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$object = new self();
|
||||
$object->type = PaidMediaType::PREVIEW;
|
||||
$object->width = $data['width'] ?? null;
|
||||
$object->height = $data['height'] ?? null;
|
||||
|
|
|
@ -35,10 +35,14 @@ class PaidMediaVideo extends PaidMedia implements ObjectTypeInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): PaidMediaVideo
|
||||
public static function fromArray(?array $data): ?PaidMediaVideo
|
||||
{
|
||||
$object = new self();
|
||||
if($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$object = new self();
|
||||
$object->type = PaidMediaType::VIDEO;
|
||||
$object->video = Video::fromArray($data['video']);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue