1 | <?php |
||
15 | class UserProfilePhotos extends Entity |
||
16 | { |
||
17 | /** |
||
18 | * @var mixed|null |
||
19 | */ |
||
20 | protected $total_count; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $photos; |
||
26 | |||
27 | /** |
||
28 | * UserProfilePhotos constructor. |
||
29 | * |
||
30 | * @param array $data |
||
31 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
32 | */ |
||
33 | 1 | public function __construct(array $data) |
|
34 | { |
||
35 | |||
36 | 1 | $this->total_count = isset($data['total_count']) ? $data['total_count'] : null; |
|
37 | 1 | if ($this->total_count === null || !is_numeric($this->total_count)) { |
|
38 | throw new TelegramException('total_count is empty!'); |
||
39 | } |
||
40 | 1 | $this->photos = isset($data['photos']) ? $data['photos'] : null; |
|
41 | 1 | if ($this->photos === null || !is_array($data['photos'])) { |
|
42 | throw new TelegramException('photos is empty!'); |
||
43 | } |
||
44 | |||
45 | 1 | $photos = []; |
|
46 | 1 | foreach ($this->photos as $key => $photo) { |
|
47 | 1 | if (is_array($photo)) { |
|
48 | 1 | foreach ($photo as $photo_size) { |
|
49 | 1 | $photos[$key][] = new PhotoSize($photo_size); |
|
50 | } |
||
51 | } else { |
||
52 | 1 | throw new TelegramException('photo is not an array!'); |
|
53 | } |
||
54 | } |
||
55 | |||
56 | 1 | $this->photos = $photos; |
|
57 | 1 | } |
|
58 | |||
59 | /** |
||
60 | * Get total count |
||
61 | * |
||
62 | * @return mixed|null |
||
63 | */ |
||
64 | public function getTotalCount() |
||
68 | |||
69 | /** |
||
70 | * Get photos |
||
71 | * |
||
72 | * @return array |
||
73 | */ |
||
74 | 1 | public function getPhotos() |
|
78 | } |
||
79 |