InlineQuery.php 1.67 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 InlineQuery extends Entity
{
    protected $id;
    protected $from;
19
    protected $location;
MBoretto's avatar
MBoretto committed
20 21 22
    protected $query;
    protected $offset;

MBoretto's avatar
MBoretto committed
23 24 25 26 27
    /**
     * InlineQuery constructor.
     *
     * @param array $data
     */
MBoretto's avatar
MBoretto committed
28 29 30 31 32 33 34
    public function __construct(array $data)
    {
        $this->id = isset($data['id']) ? $data['id'] : null;
        if (empty($this->id)) {
            throw new TelegramException('id is empty!');
        }

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

41 42 43 44 45
        $this->location = isset($data['location']) ? $data['location'] : null;
        if (!empty($this->location)) {
            $this->location = new Location($this->location);
        }

MBoretto's avatar
MBoretto committed
46 47 48 49 50 51 52 53
        $this->query = isset($data['query']) ? $data['query'] : null;
        $this->offset = isset($data['offset']) ? $data['offset'] : null;
    }

    public function getId()
    {
        return $this->id;
    }
54

MBoretto's avatar
MBoretto committed
55
    public function getFrom()
MBoretto's avatar
MBoretto committed
56 57 58
    {
        return $this->from;
    }
59

60 61 62 63
    public function getLocation()
    {
        return $this->location;
    }
64

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

MBoretto's avatar
MBoretto committed
70 71 72 73 74
    public function getOffset()
    {
        return $this->offset;
    }
}