InputContactMessageContent.php 1.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<?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 InputContactMessageContent extends InputMessageContent
{
    protected $phone_number;
    protected $first_name;
    protected $last_name;

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

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

Jack'lul's avatar
Jack'lul committed
38
        $this->last_name = isset($data['last_name']) ? $data['last_name'] : null;
39 40
    }
}