Audio.php 1.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?php

/*
 * This file is part of the TelegramBot package.
 *
 * (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;

use Longman\TelegramBot\Exception\TelegramException;

class Audio extends Entity
{
    protected $file_id;
    protected $duration;
MBoretto's avatar
MBoretto committed
19 20
    protected $performer;
    protected $title;
21 22 23 24 25 26 27 28 29 30 31 32
    protected $mime_type;
    protected $file_size;


    public function __construct(array $data)
    {

        $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
        if (empty($this->file_id)) {
            throw new TelegramException('file_id is empty!');
        }

MBoretto's avatar
MBoretto committed
33
        $this->duration = isset($data['duration']) ? $data['duration'] : null;
34 35 36 37
        if (empty($this->duration)) {
            throw new TelegramException('duration is empty!');
        }

MBoretto's avatar
MBoretto committed
38 39 40 41
        $this->performer = isset($data['performer']) ? $data['performer'] : null;

        $this->title = isset($data['title']) ? $data['title'] : null;
        $this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
42 43 44 45 46 47 48 49 50
        $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;

    }

    public function getFileId()
    {
        return $this->file_id;
    }

MBoretto's avatar
MBoretto committed
51
    public function getDuration()
52 53 54 55
    {
         return $this->duration;
    }

MBoretto's avatar
MBoretto committed
56 57 58 59 60 61 62 63
    public function getPerformer()
    {
        return $this->performer;
    }
    public function getTitle()
    {
        return $this->title;
    }
64 65 66 67 68 69 70 71 72 73
    public function getMimeType()
    {
         return $this->mime_type;
    }

    public function getFileSize()
    {
         return $this->file_size;
    }
}