ChosenInlineResult.php 1.72 KB
Newer Older
MBoretto's avatar
MBoretto committed
1
<?php
Jack'lul's avatar
Jack'lul committed
2
/**
MBoretto's avatar
MBoretto committed
3 4 5 6 7 8
 * 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.
Jack'lul's avatar
Jack'lul committed
9 10
 */

MBoretto's avatar
MBoretto committed
11 12 13 14 15 16 17 18
namespace Longman\TelegramBot\Entities;

use Longman\TelegramBot\Exception\TelegramException;

class ChosenInlineResult extends Entity
{
    protected $result_id;
    protected $from;
19 20
    protected $location;
    protected $inline_message_id;
MBoretto's avatar
MBoretto committed
21 22 23 24 25 26 27 28 29
    protected $query;

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

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

36 37 38 39 40 41
        $this->location = isset($data['location']) ? $data['location'] : null;
        if (!empty($this->location)) {
            $this->location = new Location($this->location);
        }

        $this->inline_message_id = isset($data['inline_message_id']) ? $data['inline_message_id'] : null;
MBoretto's avatar
MBoretto committed
42 43 44
        $this->query = isset($data['query']) ? $data['query'] : null;
    }

MBoretto's avatar
MBoretto committed
45
    public function getResultId()
MBoretto's avatar
MBoretto committed
46
    {
MBoretto's avatar
MBoretto committed
47
        return $this->result_id;
MBoretto's avatar
MBoretto committed
48 49
    }

MBoretto's avatar
MBoretto committed
50
    public function getFrom()
MBoretto's avatar
MBoretto committed
51 52 53
    {
        return $this->from;
    }
54 55 56 57 58 59 60 61 62 63 64

    public function getLocation()
    {
        return $this->location;
    }

    public function getInlineMessageId()
    {
        return $this->inline_message_id;
    }

MBoretto's avatar
MBoretto committed
65 66 67 68 69
    public function getQuery()
    {
        return $this->query;
    }
}