Completed
Pull Request — develop (#304)
by
unknown
02:52
created

Audio   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 95.83%

Importance

Changes 0
Metric Value
wmc 16
lcom 0
cbo 2
dl 0
loc 117
ccs 23
cts 24
cp 0.9583
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 18 10
A getFileId() 0 4 1
A getDuration() 0 4 1
A getPerformer() 0 4 1
A getTitle() 0 4 1
A getMimeType() 0 4 1
A getFileSize() 0 4 1
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 Audio extends Entity
16
{
17
    /**
18
     * @var mixed|null
19
     */
20
    protected $file_id;
21
22
    /**
23
     * @var mixed|null
24
     */
25
    protected $duration;
26
27
    /**
28
     * @var mixed|null
29
     */
30
    protected $performer;
31
32
    /**
33
     * @var mixed|null
34
     */
35
    protected $title;
36
37
    /**
38
     * @var mixed|null
39
     */
40
    protected $mime_type;
41
42
    /**
43
     * @var mixed|null
44
     */
45
    protected $file_size;
46
47
    /**
48
     * Audio constructor.
49
     *
50
     * @param array $data
51
     * @throws \Longman\TelegramBot\Exception\TelegramException
52
     */
53 9
    public function __construct(array $data)
54
    {
55 9
        $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
56 9
        if (empty($this->file_id)) {
57
            throw new TelegramException('file_id is empty!');
58
        }
59
60 9
        $this->duration = isset($data['duration']) ? $data['duration'] : null;
61 9
        if ($this->duration === '' || $this->duration === null) {
62 2
            throw new TelegramException('duration is empty!');
63
        }
64
65 7
        $this->performer = isset($data['performer']) ? $data['performer'] : null;
66
67 7
        $this->title     = isset($data['title']) ? $data['title'] : null;
68 7
        $this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
69 7
        $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
70 7
    }
71
72
    /**
73
     * Get file id
74
     *
75
     * @return mixed|null
76
     */
77 1
    public function getFileId()
78
    {
79 1
        return $this->file_id;
80
    }
81
82
    /**
83
     * Get duration
84
     *
85
     * @return mixed|null
86
     */
87 1
    public function getDuration()
88
    {
89 1
        return $this->duration;
90
    }
91
92
    /**
93
     * Get performer
94
     *
95
     * @return mixed|null
96
     */
97 1
    public function getPerformer()
98
    {
99 1
        return $this->performer;
100
    }
101
102
    /**
103
     * Get title
104
     *
105
     * @return mixed|null
106
     */
107 1
    public function getTitle()
108
    {
109 1
        return $this->title;
110
    }
111
112
    /**
113
     * Get mime type
114
     *
115
     * @return mixed|null
116
     */
117 1
    public function getMimeType()
118
    {
119 1
        return $this->mime_type;
120
    }
121
122
    /**
123
     * Get file size
124
     *
125
     * @return mixed|null
126
     */
127 1
    public function getFileSize()
128
    {
129 1
        return $this->file_size;
130
    }
131
}
132