Code Duplication    Length = 48-54 lines in 2 locations

src/Entities/Contact.php 1 location

@@ 15-62 (lines=48) @@
12
13
use Longman\TelegramBot\Exception\TelegramException;
14
15
class Contact extends Entity
16
{
17
    /**
18
     * @var mixed|null
19
     */
20
    protected $phone_number;
21
22
    /**
23
     * @var mixed|null
24
     */
25
    protected $first_name;
26
27
    /**
28
     * @var mixed|null
29
     */
30
    protected $last_name;
31
32
    /**
33
     * @var mixed|null
34
     */
35
    protected $user_id;
36
37
    /**
38
     * Contact constructor.
39
     *
40
     * @param array $data
41
     * @throws \Longman\TelegramBot\Exception\TelegramException
42
     */
43
    public function __construct(array $data)
44
    {
45
        $this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null;
46
        if (empty($this->phone_number)) {
47
            throw new TelegramException('phone_number is empty!');
48
        }
49
50
        $this->first_name = isset($data['first_name']) ? $data['first_name'] : null;
51
        if (empty($this->first_name)) {
52
            throw new TelegramException('first_name is empty!');
53
        }
54
55
        $this->last_name = isset($data['last_name']) ? $data['last_name'] : null;
56
        $this->user_id   = isset($data['user_id']) ? $data['user_id'] : null;
57
    }
58
59
    /**
60
     * Get phone number
61
     *
62
     * @return mixed|null
63
     */
64
    public function getPhoneNumber()
65
    {

src/Entities/PhotoSize.php 1 location

@@ 15-68 (lines=54) @@
12
13
use Longman\TelegramBot\Exception\TelegramException;
14
15
class PhotoSize extends Entity
16
{
17
    /**
18
     * @var mixed|null
19
     */
20
    protected $file_id;
21
22
    /**
23
     * @var mixed|null
24
     */
25
    protected $width;
26
27
    /**
28
     * @var mixed|null
29
     */
30
    protected $height;
31
32
    /**
33
     * @var mixed|null
34
     */
35
    protected $file_size;
36
37
    /**
38
     * PhotoSize constructor.
39
     *
40
     * @param array $data
41
     * @throws \Longman\TelegramBot\Exception\TelegramException
42
     */
43
    public function __construct(array $data)
44
    {
45
46
        $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
47
        if (empty($this->file_id)) {
48
            throw new TelegramException('file_id is empty!');
49
        }
50
51
        $this->width = isset($data['width']) ? $data['width'] : null;
52
        if (empty($this->width)) {
53
            throw new TelegramException('width is empty!');
54
        }
55
56
        $this->height = isset($data['height']) ? $data['height'] : null;
57
        if (empty($this->height)) {
58
            throw new TelegramException('height is empty!');
59
        }
60
61
        $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
62
    }
63
64
    /**
65
     * Get file id
66
     *
67
     * @return mixed|null
68
     */
69
    public function getFileId()
70
    {
71
        return $this->file_id;