Completed
Pull Request — develop (#326)
by
unknown
04:31
created

File::__construct()   B

Complexity

Conditions 5
Paths 10

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 8.8571
cc 5
eloc 6
nc 10
nop 1
crap 5
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
class File extends Entity
16
{
17
    /**
18
     * @var mixed|null
19
     */
20
    protected $file_id;
21
22
    /**
23
     * @var mixed|null
24
     */
25
    protected $file_size;
26
27
    /**
28
     * @var mixed|null
29
     */
30
    protected $file_path;
31
32
    /**
33
     * File constructor.
34
     *
35
     * @param array $data
36
     * @throws \Longman\TelegramBot\Exception\TelegramException
37
     */
38 8
    public function __construct(array $data)
39
    {
40 8
        $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
41 8
        if (empty($this->file_id)) {
42 1
            throw new TelegramException('file_id is empty!');
43
        }
44
45 7
        $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
46
47 7
        $this->file_path = isset($data['file_path']) ? $data['file_path'] : null;
48 7
    }
49
50
    /**
51
     * Get file id
52
     *
53
     * @return mixed|null
54
     */
55 1
    public function getFileId()
56
    {
57 1
        return $this->file_id;
58
    }
59
60
    /**
61
     * Get file size
62
     *
63
     * @return mixed|null
64
     */
65 2
    public function getFileSize()
66
    {
67 2
        return $this->file_size;
68
    }
69
70
    /**
71
     * Get file path
72
     *
73
     * @return mixed|null
74
     */
75 2
    public function getFilePath()
76
    {
77 2
        return $this->file_path;
78
    }
79
}
80