Code Duplication    Length = 11-13 lines in 15 locations

src/wormling/phparia/Api/MediaBase.php 2 locations

@@ 55-67 (lines=13) @@
52
     * @throws NotFoundException
53
     * @throws ConflictException
54
     */
55
    public function startMusicOnHold($id, $mohClass)
56
    {
57
        $uri = "/{$this->getType()}/$id/moh";
58
        try {
59
            $this->client->getEndpoint()->post($uri, array(
60
                'mohClass' => $mohClass,
61
            ));
62
        } catch (Pest_NotFound $e) {
63
            throw new NotFoundException($e);
64
        } catch (Pest_Conflict $e) {
65
            throw new ConflictException($e);
66
        }
67
    }
68
69
    /**
70
     * Stop playing music on hold to a channel.
@@ 76-86 (lines=11) @@
73
     * @throws NotFoundException
74
     * @throws ConflictException
75
     */
76
    public function stopMusicOnHold($id)
77
    {
78
        $uri = "/{$this->getType()}/$id/moh";
79
        try {
80
            $this->client->getEndpoint()->delete($uri);
81
        } catch (Pest_NotFound $e) {
82
            throw new NotFoundException($e);
83
        } catch (Pest_Conflict $e) {
84
            throw new ConflictException($e);
85
        }
86
    }
87
88
    /**
89
     * Start playback of media. The media URI may be any of a number of URI's. Currently sound:,

src/wormling/phparia/Api/Recordings.php 4 locations

@@ 175-185 (lines=11) @@
172
     * @throws ConflictException
173
     * @throws NotFoundException
174
     */
175
    public function pauseLiveRecording($recordingName)
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.
@@ 194-204 (lines=11) @@
191
     * @throws ConflictException
192
     * @throws NotFoundException
193
     */
194
    public function unpauseLiveRecording($recordingName)
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.
@@ 213-223 (lines=11) @@
210
     * @throws ConflictException
211
     * @throws NotFoundException
212
     */
213
    public function muteLiveRecording($recordingName)
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.
@@ 232-242 (lines=11) @@
229
     * @throws ConflictException
230
     * @throws NotFoundException
231
     */
232
    public function unmuteLiveRecording($recordingName)
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

src/wormling/phparia/Api/DeviceStates.php 1 location

@@ 106-116 (lines=11) @@
103
     * @throws ConflictException
104
     * @throws NotFoundException
105
     */
106
    public function deleteDeviceState($deviceName)
107
    {
108
        $uri = "/deviceStates/$deviceName";
109
        try {
110
            $this->client->getEndpoint()->delete($uri);
111
        } catch (Pest_NotFound $e) {
112
            throw new NotFoundException($e);
113
        } catch (Pest_Conflict $e) {
114
            throw new ConflictException($e);
115
        }
116
    }
117
118
}
119

src/wormling/phparia/Api/Channels.php 8 locations

@@ 268-278 (lines=11) @@
265
     * @throws NotFoundException
266
     * @throws ConflictException
267
     */
268
    public function answer($channelId)
269
    {
270
        $uri = "/channels/$channelId/answer";
271
        try {
272
            $this->client->getEndpoint()->post($uri, array());
273
        } catch (Pest_NotFound $e) {
274
            throw new NotFoundException($e);
275
        } catch (Pest_Conflict $e) {
276
            throw new ConflictException($e);
277
        }
278
    }
279
280
    /**
281
     * Indicate ringing to a channel.
@@ 287-297 (lines=11) @@
284
     * @throws NotFoundException
285
     * @throws ConflictException
286
     */
287
    public function startRinging($channelId)
288
    {
289
        $uri = "/channels/$channelId/ring";
290
        try {
291
            $this->client->getEndpoint()->post($uri, array());
292
        } catch (Pest_NotFound $e) {
293
            throw new NotFoundException($e);
294
        } catch (Pest_Conflict $e) {
295
            throw new ConflictException($e);
296
        }
297
    }
298
299
    /**
300
     * Stop ringing indication on a channel if locally generated.
@@ 306-316 (lines=11) @@
303
     * @throws NotFoundException
304
     * @throws ConflictException
305
     */
306
    public function stopRinging($channelId)
307
    {
308
        $uri = "/channels/$channelId/ring";
309
        try {
310
            $this->client->getEndpoint()->delete($uri);
311
        } catch (Pest_NotFound $e) {
312
            throw new NotFoundException($e);
313
        } catch (Pest_Conflict $e) {
314
            throw new ConflictException($e);
315
        }
316
    }
317
318
    /**
319
     * Send provided DTMF to a given channel.
@@ 381-391 (lines=11) @@
378
     * @throws NotFoundException
379
     * @throws ConflictException
380
     */
381
    public function unmute($channelId, $direction)
382
    {
383
        $uri = "/channels/$channelId/mute?direction=".$this->client->getEndpoint()->jsonEncode($direction);
384
        try {
385
            $this->client->getEndpoint()->delete($uri);
386
        } catch (Pest_NotFound $e) {
387
            throw new NotFoundException($e);
388
        } catch (Pest_Conflict $e) {
389
            throw new ConflictException($e);
390
        }
391
    }
392
393
    /**
394
     * Hold a channel.
@@ 400-410 (lines=11) @@
397
     * @throws NotFoundException
398
     * @throws ConflictException
399
     */
400
    public function hold($channelId)
401
    {
402
        $uri = "/channels/$channelId/hold";
403
        try {
404
            $this->client->getEndpoint()->post($uri, array());
405
        } catch (Pest_NotFound $e) {
406
            throw new NotFoundException($e);
407
        } catch (Pest_Conflict $e) {
408
            throw new ConflictException($e);
409
        }
410
    }
411
412
    /**
413
     * Remove a channel from hold.
@@ 419-429 (lines=11) @@
416
     * @throws NotFoundException
417
     * @throws ConflictException
418
     */
419
    public function unhold($channelId)
420
    {
421
        $uri = "/channels/$channelId/hold";
422
        try {
423
            $this->client->getEndpoint()->delete($uri);
424
        } catch (Pest_NotFound $e) {
425
            throw new NotFoundException($e);
426
        } catch (Pest_Conflict $e) {
427
            throw new ConflictException($e);
428
        }
429
    }
430
431
    /**
432
     * Play silence to a channel. Using media operations such as /play on a channel playing silence in this manner will suspend silence without resuming automatically.
@@ 438-448 (lines=11) @@
435
     * @throws NotFoundException
436
     * @throws ConflictException
437
     */
438
    public function startSilence($channelId)
439
    {
440
        $uri = "/channels/$channelId/silence";
441
        try {
442
            $this->client->getEndpoint()->post($uri, array());
443
        } catch (Pest_NotFound $e) {
444
            throw new NotFoundException($e);
445
        } catch (Pest_Conflict $e) {
446
            throw new ConflictException($e);
447
        }
448
    }
449
450
    /**
451
     * Stop playing silence to a channel.
@@ 457-467 (lines=11) @@
454
     * @throws NotFoundException
455
     * @throws ConflictException
456
     */
457
    public function stopSilence($channelId)
458
    {
459
        $uri = "/channels/$channelId/silence";
460
        try {
461
            $this->client->getEndpoint()->delete($uri);
462
        } catch (Pest_NotFound $e) {
463
            throw new NotFoundException($e);
464
        } catch (Pest_Conflict $e) {
465
            throw new ConflictException($e);
466
        }
467
    }
468
469
    /**
470
     * Get the value of a channel variable or function.