LiveRecording   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 173
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 1
dl 0
loc 173
ccs 0
cts 68
cp 0
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getCause() 0 4 1
A getDuration() 0 4 1
A getFormat() 0 4 1
A getName() 0 4 1
A getSilenceDuration() 0 4 1
A getState() 0 4 1
A getTalkingDuration() 0 4 1
A getTargetUri() 0 4 1
A onRecordingFailed() 0 4 1
A onceRecordingFailed() 0 4 1
A onRecordingFinished() 0 4 1
A onceRecordingFinished() 0 4 1
A onRecordingStarted() 0 4 1
A onceRecordingStarted() 0 4 1
A __construct() 0 13 1
1
<?php
2
3
/*
4
 * Copyright 2014 Brian Smith <[email protected]>.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *      http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace phparia\Resources;
20
21
use phparia\Client\AriClient;
22
use phparia\Events\Event;
23
24
/**
25
 * A recording that is in progress
26
 *
27
 * @author Brian Smith <[email protected]>
28
 */
29
class LiveRecording extends Resource
30
{
31
    /**
32
     * @var string (optional) - Cause for recording failure if failed
33
     */
34
    private $cause;
35
36
    /**
37
     * @var int (optional) - Duration in seconds of the recording
38
     */
39
    private $duration;
40
41
    /**
42
     * @var string Recording format (wav, gsm, etc.)
43
     */
44
    private $format;
45
46
    /**
47
     * @var string Base name for the recording
48
     */
49
    private $name;
50
51
    /**
52
     * @var int (optional) - Duration of silence, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds.
53
     */
54
    private $silenceDuration;
55
56
    /**
57
     * @var string
58
     */
59
    private $state;
60
61
    /**
62
     * @var int (optional) - Duration of talking, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds.
63
     */
64
    private $talkingDuration;
65
66
    /**
67
     * @var string URI for the channel or bridge being recorded
68
     */
69
    private $targetUri;
70
71
    /**
72
     * @return string (optional) - Cause for recording failure if failed
73
     */
74
    public function getCause()
75
    {
76
        return $this->cause;
77
    }
78
79
    /**
80
     * @return int (optional) - Duration in seconds of the recording
81
     */
82
    public function getDuration()
83
    {
84
        return $this->duration;
85
    }
86
87
    /**
88
     * @return string Recording format (wav, gsm, etc.)
89
     */
90
    public function getFormat()
91
    {
92
        return $this->format;
93
    }
94
95
    /**
96
     * @return string Base name for the recording
97
     */
98
    public function getName()
99
    {
100
        return $this->name;
101
    }
102
103
    /**
104
     * @return int (optional) - Duration of silence, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds.
105
     */
106
    public function getSilenceDuration()
107
    {
108
        return $this->silenceDuration;
109
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function getState()
115
    {
116
        return $this->state;
117
    }
118
119
    /**
120
     * @return int (optional) - Duration of talking, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds.
121
     */
122
    public function getTalkingDuration()
123
    {
124
        return $this->talkingDuration;
125
    }
126
127
    /**
128
     * @return string URI for the channel or bridge being recorded
129
     */
130
    public function getTargetUri()
131
    {
132
        return $this->targetUri;
133
    }
134
135
    /**
136
     * @param callable $callback
137
     */
138
    public function onRecordingFailed(callable $callback)
139
    {
140
        $this->on(Event::RECORDING_FAILED.'_'.$this->getName(), $callback);
141
    }
142
143
    /**
144
     * @param callable $callback
145
     */
146
    public function onceRecordingFailed(callable $callback)
147
    {
148
        $this->once(Event::RECORDING_FAILED.'_'.$this->getName(), $callback);
149
    }
150
151
    /**
152
     * @param callable $callback
153
     */
154
    public function onRecordingFinished(callable $callback)
155
    {
156
        $this->on(Event::RECORDING_FINISHED.'_'.$this->getName(), $callback);
157
    }
158
159
    /**
160
     * @param callable $callback
161
     */
162
    public function onceRecordingFinished(callable $callback)
163
    {
164
        $this->once(Event::RECORDING_FINISHED.'_'.$this->getName(), $callback);
165
    }
166
167
    /**
168
     * @param callable $callback
169
     */
170
    public function onRecordingStarted(callable $callback)
171
    {
172
        $this->on(Event::RECORDING_STARTED.'_'.$this->getName(), $callback);
173
    }
174
175
    /**
176
     * @param callable $callback
177
     */
178
    public function onceRecordingStarted(callable $callback)
179
    {
180
        $this->once(Event::RECORDING_STARTED.'_'.$this->getName(), $callback);
181
    }
182
183
    /**
184
     * @param AriClient $client
185
     * @param string $response
186
     */
187
    public function __construct(AriClient $client, $response)
188
    {
189
        parent::__construct($client, $response);
190
191
        $this->cause = $this->getResponseValue('cause');
192
        $this->duration = $this->getResponseValue('duration');
193
        $this->format = $this->getResponseValue('format');
194
        $this->name = $this->getResponseValue('name');
195
        $this->silenceDuration = $this->getResponseValue('silence_duration');
196
        $this->state = $this->getResponseValue('state');
197
        $this->talkingDuration = $this->getResponseValue('talking_duration');
198
        $this->targetUri = $this->getResponseValue('target_uri');
199
    }
200
201
}
202