Completed
Push — feature/improve-code ( e986a1...36787d )
by Avtandil
14:14
created

PhotoSize::__construct()   B

Complexity

Conditions 8
Paths 30

Size

Total Lines 20
Code Lines 11

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 9

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 20
loc 20
rs 7.7777
ccs 9
cts 12
cp 0.75
cc 8
eloc 11
nc 30
nop 1
crap 9
1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Entities;
12
13
use Longman\TelegramBot\Exception\TelegramException;
14
15 View Code Duplication
class PhotoSize extends Entity
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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 1
    public function __construct(array $data)
44
    {
45
46 1
        $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
47 1
        if (empty($this->file_id)) {
48
            throw new TelegramException('file_id is empty!');
49
        }
50
51 1
        $this->width = isset($data['width']) ? $data['width'] : null;
52 1
        if (empty($this->width)) {
53
            throw new TelegramException('width is empty!');
54
        }
55
56 1
        $this->height = isset($data['height']) ? $data['height'] : null;
57 1
        if (empty($this->height)) {
58
            throw new TelegramException('height is empty!');
59
        }
60
61 1
        $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
62 1
    }
63
64
    /**
65
     * Get file id
66
     *
67
     * @return mixed|null
68
     */
69
    public function getFileId()
70
    {
71
        return $this->file_id;
72
    }
73
74
    /**
75
     * Get width
76
     *
77
     * @return mixed|null
78
     */
79
    public function getWidth()
80
    {
81
        return $this->width;
82
    }
83
84
    /**
85
     * Get height
86
     *
87
     * @return mixed|null
88
     */
89
    public function getHeight()
90
    {
91
        return $this->height;
92
    }
93
94
    /**
95
     * Get file size
96
     *
97
     * @return mixed|null
98
     */
99
    public function getFileSize()
100
    {
101
        return $this->file_size;
102
    }
103
}
104