| 1 | <?php |
||
| 15 | class Audio extends Entity |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var mixed|null |
||
| 19 | */ |
||
| 20 | protected $file_id; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var mixed|null |
||
| 24 | */ |
||
| 25 | protected $duration; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var mixed|null |
||
| 29 | */ |
||
| 30 | protected $performer; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var mixed|null |
||
| 34 | */ |
||
| 35 | protected $title; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var mixed|null |
||
| 39 | */ |
||
| 40 | protected $mime_type; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var mixed|null |
||
| 44 | */ |
||
| 45 | protected $file_size; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Audio constructor. |
||
| 49 | * |
||
| 50 | * @param array $data |
||
| 51 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 52 | */ |
||
| 53 | 9 | public function __construct(array $data) |
|
| 54 | { |
||
| 55 | 9 | $this->file_id = isset($data['file_id']) ? $data['file_id'] : null; |
|
| 56 | 9 | if (empty($this->file_id)) { |
|
| 57 | 1 | throw new TelegramException('file_id is empty!'); |
|
| 58 | } |
||
| 59 | |||
| 60 | 8 | $this->duration = isset($data['duration']) ? $data['duration'] : null; |
|
| 61 | 8 | if ($this->duration === '' || $this->duration === null) { |
|
| 62 | 1 | throw new TelegramException('duration is empty!'); |
|
| 63 | } |
||
| 64 | |||
| 65 | 7 | $this->performer = isset($data['performer']) ? $data['performer'] : null; |
|
| 66 | |||
| 67 | 7 | $this->title = isset($data['title']) ? $data['title'] : null; |
|
| 68 | 7 | $this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null; |
|
| 69 | 7 | $this->file_size = isset($data['file_size']) ? $data['file_size'] : null; |
|
| 70 | 7 | } |
|
| 71 | |||
| 72 | /** |
||
| 73 | * Get file id |
||
| 74 | * |
||
| 75 | * @return mixed|null |
||
| 76 | */ |
||
| 77 | 1 | public function getFileId() |
|
| 81 | |||
| 82 | /** |
||
| 83 | * Get duration |
||
| 84 | * |
||
| 85 | * @return mixed|null |
||
| 86 | */ |
||
| 87 | 1 | public function getDuration() |
|
| 91 | |||
| 92 | /** |
||
| 93 | * Get performer |
||
| 94 | * |
||
| 95 | * @return mixed|null |
||
| 96 | */ |
||
| 97 | 1 | public function getPerformer() |
|
| 101 | |||
| 102 | /** |
||
| 103 | * Get title |
||
| 104 | * |
||
| 105 | * @return mixed|null |
||
| 106 | */ |
||
| 107 | 1 | public function getTitle() |
|
| 111 | |||
| 112 | /** |
||
| 113 | * Get mime type |
||
| 114 | * |
||
| 115 | * @return mixed|null |
||
| 116 | */ |
||
| 117 | 1 | public function getMimeType() |
|
| 121 | |||
| 122 | /** |
||
| 123 | * Get file size |
||
| 124 | * |
||
| 125 | * @return mixed|null |
||
| 126 | */ |
||
| 127 | 1 | public function getFileSize() |
|
| 131 | } |
||
| 132 |