These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\Api; |
||
20 | |||
21 | use Pest_Conflict; |
||
22 | use Pest_NotFound; |
||
23 | use phparia\Client\AriClientAware; |
||
24 | use phparia\Exception\ConflictException; |
||
25 | use phparia\Exception\NotFoundException; |
||
26 | use phparia\Resources\LiveRecording; |
||
27 | use phparia\Resources\StoredRecording; |
||
28 | |||
29 | /** |
||
30 | * Recordings API |
||
31 | * |
||
32 | * @author Brian Smith <[email protected]> |
||
33 | */ |
||
34 | class Recordings extends AriClientAware |
||
35 | { |
||
36 | /** |
||
37 | * List recordings that are complete. |
||
38 | * |
||
39 | * @return StoredRecording[] |
||
40 | */ |
||
41 | 2 | public function getRecordings() |
|
42 | { |
||
43 | 2 | $uri = '/recordings/stored'; |
|
44 | 2 | $response = $this->client->getEndpoint()->get($uri); |
|
45 | |||
46 | 2 | $recordings = []; |
|
47 | 2 | foreach ((array)$response as $recording) { |
|
48 | 2 | $recordings[] = new StoredRecording($recording); |
|
49 | 2 | } |
|
50 | |||
51 | 2 | return $recordings; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * Get a stored recording's details. |
||
56 | * |
||
57 | * @param string $recordingName The name of the recording |
||
58 | * @return StoredRecording |
||
59 | * @throws NotFoundException |
||
60 | */ |
||
61 | 3 | public function getRecording($recordingName) |
|
62 | { |
||
63 | 3 | $uri = "/recordings/stored/$recordingName"; |
|
64 | try { |
||
65 | 3 | $response = $this->client->getEndpoint()->get($uri); |
|
66 | 3 | } catch (Pest_NotFound $e) { // Playback not found |
|
67 | 1 | throw new NotFoundException($e); |
|
68 | } |
||
69 | |||
70 | 2 | return new StoredRecording($response); |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * Delete a stored recording. |
||
75 | * |
||
76 | * @param string $recordingName The name of the recording |
||
77 | * @return StoredRecording |
||
78 | * @throws NotFoundException |
||
79 | */ |
||
80 | 2 | View Code Duplication | public function deleteRecording($recordingName) |
0 ignored issues
–
show
|
|||
81 | { |
||
82 | 2 | $uri = "/recordings/stored/$recordingName"; |
|
83 | try { |
||
84 | 2 | $this->client->getEndpoint()->delete($uri); |
|
85 | 2 | } catch (Pest_NotFound $e) { // Playback not found |
|
86 | throw new NotFoundException($e); |
||
87 | } |
||
88 | 2 | } |
|
89 | |||
90 | /** |
||
91 | * Copy a stored recording. |
||
92 | * |
||
93 | * @param string $recordingName The name of the recording to copy |
||
94 | * @param string $destinationRecordingName (required) The destination name of the recording |
||
95 | * @return StoredRecording |
||
96 | * @throws ConflictException |
||
97 | * @throws NotFoundException |
||
98 | */ |
||
99 | 1 | View Code Duplication | public function copyRecording($recordingName, $destinationRecordingName) |
0 ignored issues
–
show
This method 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...
|
|||
100 | { |
||
101 | 1 | $uri = "/recordings/stored/$recordingName/copy"; |
|
102 | try { |
||
103 | 1 | $response = $this->client->getEndpoint()->post($uri, array( |
|
104 | 1 | 'destinationRecordingName' => $destinationRecordingName, |
|
105 | 1 | )); |
|
106 | 1 | } catch (Pest_NotFound $e) { |
|
107 | throw new NotFoundException($e); |
||
108 | } catch (Pest_Conflict $e) { |
||
109 | throw new ConflictException($e); |
||
110 | } |
||
111 | |||
112 | 1 | return new StoredRecording($response); |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * Get live recording |
||
117 | * |
||
118 | * @param string $recordingName The name of the recording |
||
119 | * @return LiveRecording |
||
120 | * @throws NotFoundException |
||
121 | */ |
||
122 | public function getLiveRecording($recordingName) |
||
123 | { |
||
124 | $uri = "/recordings/live/$recordingName"; |
||
125 | try { |
||
126 | $response = $this->client->getEndpoint()->get($uri); |
||
127 | } catch (Pest_NotFound $e) { // Playback not found |
||
128 | throw new NotFoundException($e); |
||
129 | } |
||
130 | |||
131 | return new LiveRecording($this->client, $response); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Stop a live recording and discard it. |
||
136 | * |
||
137 | * @param string $recordingName The name of the recording |
||
138 | * @throws NotFoundException |
||
139 | */ |
||
140 | View Code Duplication | public function deleteLiveRecording($recordingName) |
|
0 ignored issues
–
show
This method 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...
|
|||
141 | { |
||
142 | $uri = "/recordings/live/$recordingName"; |
||
143 | try { |
||
144 | $this->client->getEndpoint()->delete($uri); |
||
145 | } catch (Pest_NotFound $e) { // Playback not found |
||
146 | throw new NotFoundException($e); |
||
147 | } |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * Stop a live recording and store it. |
||
152 | * |
||
153 | * @param string $recordingName The name of the recording |
||
154 | * @throws NotFoundException |
||
155 | */ |
||
156 | View Code Duplication | public function stopLiveRecording($recordingName) |
|
0 ignored issues
–
show
This method 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...
|
|||
157 | { |
||
158 | $uri = "/recordings/live/$recordingName/stop"; |
||
159 | try { |
||
160 | $this->client->getEndpoint()->post($uri, array()); |
||
161 | } catch (Pest_NotFound $e) { // Playback not found |
||
162 | throw new NotFoundException($e); |
||
163 | } |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * Pause a live recording. Pausing a recording suspends silence detection, which will be restarted |
||
168 | * when the recording is unpaused. Paused time is not included in the accounting for |
||
169 | * maxDurationSeconds. |
||
170 | * |
||
171 | * @param string $recordingName The name of the recording |
||
172 | * @throws ConflictException |
||
173 | * @throws NotFoundException |
||
174 | */ |
||
175 | View Code Duplication | public function pauseLiveRecording($recordingName) |
|
0 ignored issues
–
show
This method 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...
|
|||
176 | { |
||
177 | $uri = "/recordings/live/$recordingName/pause"; |
||
178 | try { |
||
179 | $this->client->getEndpoint()->post($uri, array()); |
||
180 | } catch (Pest_NotFound $e) { |
||
181 | throw new NotFoundException($e); |
||
182 | } catch (Pest_Conflict $e) { |
||
183 | throw new ConflictException($e); |
||
184 | } |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * Unause a live recording. |
||
189 | * |
||
190 | * @param string $recordingName The name of the recording |
||
191 | * @throws ConflictException |
||
192 | * @throws NotFoundException |
||
193 | */ |
||
194 | View Code Duplication | public function unpauseLiveRecording($recordingName) |
|
0 ignored issues
–
show
This method 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...
|
|||
195 | { |
||
196 | $uri = "/recordings/live/$recordingName/pause"; |
||
197 | try { |
||
198 | $this->client->getEndpoint()->delete($uri); |
||
199 | } catch (Pest_NotFound $e) { |
||
200 | throw new NotFoundException($e); |
||
201 | } catch (Pest_Conflict $e) { |
||
202 | throw new ConflictException($e); |
||
203 | } |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * Mute a live recording. Muting a recording suspends silence detection, which will be restarted when the recording is unmuted. |
||
208 | * |
||
209 | * @param string $recordingName The name of the recording |
||
210 | * @throws ConflictException |
||
211 | * @throws NotFoundException |
||
212 | */ |
||
213 | View Code Duplication | public function muteLiveRecording($recordingName) |
|
0 ignored issues
–
show
This method 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...
|
|||
214 | { |
||
215 | $uri = "/recordings/live/$recordingName/mute"; |
||
216 | try { |
||
217 | $this->client->getEndpoint()->post($uri, array()); |
||
218 | } catch (Pest_NotFound $e) { |
||
219 | throw new NotFoundException($e); |
||
220 | } catch (Pest_Conflict $e) { |
||
221 | throw new ConflictException($e); |
||
222 | } |
||
223 | } |
||
224 | |||
225 | /** |
||
226 | * Unmute a live recording. |
||
227 | * |
||
228 | * @param string $recordingName The name of the recording |
||
229 | * @throws ConflictException |
||
230 | * @throws NotFoundException |
||
231 | */ |
||
232 | View Code Duplication | public function unmuteLiveRecording($recordingName) |
|
0 ignored issues
–
show
This method 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...
|
|||
233 | { |
||
234 | $uri = "/recordings/live/$recordingName/mute"; |
||
235 | try { |
||
236 | $this->client->getEndpoint()->delete($uri); |
||
237 | } catch (Pest_NotFound $e) { |
||
238 | throw new NotFoundException($e); |
||
239 | } catch (Pest_Conflict $e) { |
||
240 | throw new ConflictException($e); |
||
241 | } |
||
242 | } |
||
243 | |||
244 | } |
||
245 |
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.