Completed
Push — master ( 55c5df...731aa4 )
by Brian
05:10
created

Channel   C

Complexity

Total Complexity 61

Size/Duplication

Total Lines 669
Duplicated Lines 1.79 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 14.86%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 61
c 2
b 0
f 0
lcom 1
cbo 5
dl 12
loc 669
ccs 26
cts 175
cp 0.1486
rs 5.3672

60 Methods

Rating   Name   Duplication   Size   Complexity  
A getAccountCode() 0 4 1
A getCaller() 0 4 1
A getConnected() 0 4 1
A getCreationTime() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
A getState() 0 4 1
A onStasisEnd() 0 4 1
A onceStasisEnd() 0 4 1
A onStasisStart() 0 4 1
A onceStasisStart() 0 4 1
A onChannelCallerId() 0 4 1
A onceChannelCallerId() 0 4 1
A onChannelCreated() 0 4 1
A onceChannelCreated() 0 4 1
A onChannelDestroyed() 0 4 1
A onceChannelDestroyed() 0 4 1
A removeChannelDestroyedListener() 0 4 1
A onChannelDtmfReceived() 0 4 1
A onceChannelDtmfReceived() 0 4 1
A onChannelEnteredBridge() 0 4 1
A onceChannelEnteredBridge() 0 4 1
A onChannelHangupRequest() 0 4 1
A onceChannelHangupRequest() 0 4 1
A onChannelLeftBridge() 0 4 1
A onceChannelLeftBridge() 0 4 1
A onChannelStateChange() 0 4 1
A onceChannelStateChange() 0 4 1
A onChannelTalkingFinished() 0 4 1
A onceChannelTalkingFinished() 0 4 1
A onChannelTalkingStarted() 0 4 1
A onceChannelTalkingStarted() 0 4 1
A onChannelUserevent() 0 4 1
A onceChannelUserevent() 0 4 1
A onChannelVarset() 0 4 1
A onceChannelVarset() 0 4 1
A deleteChannel() 0 4 1
A continueDialplan() 0 4 1
A answer() 0 4 1
A startRinging() 0 4 1
A stopRinging() 0 4 1
A sendDtmf() 0 4 1
A mute() 0 4 1
A unmute() 0 4 1
A hold() 0 4 1
A unhold() 0 4 1
A startMusicOnHold() 0 4 1
A stopMusicOnHold() 0 4 1
A startSilence() 0 4 1
A stopSilence() 0 4 1
A hangup() 0 4 1
A getVariable() 0 4 1
A setVariable() 0 4 1
A startSnoop() 0 4 1
A startSnoopWithId() 0 4 1
A playMedia() 0 4 1
A getDialplan() 0 4 1
A playMediaWithId() 0 5 1
A record() 12 12 1
A __construct() 0 13 2

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like Channel often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Channel, and based on these observations, apply Extract Interface, too.

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 DateTime;
22
use phparia\Client\AriClient;
23
use phparia\Events\Event;
24
use phparia\Exception\ConflictException;
25
use phparia\Exception\InvalidParameterException;
26
use phparia\Exception\NotFoundException;
27
use phparia\Exception\UnprocessableEntityException;
28
29
/**
30
 * A specific communication connection between Asterisk and an Endpoint.
31
 *
32
 * @author Brian Smith <[email protected]>
33
 */
34
class Channel extends Resource
35
{
36
    /**
37
     * @var string
38
     */
39
    private $accountCode;
40
41
    /**
42
     * @var CallerId
43
     */
44
    private $caller;
45
46
    /**
47
     * @var CallerId
48
     */
49
    private $connected;
50
51
    /**
52
     * @var DateTime
53
     */
54
    private $creationTime;
55
56
    /**
57
     * @var DialplanCep
58
     */
59
    private $dialplan;
60
61
    /**
62
     * @var string Unique identifier of the channel.  This is the same as the Uniqueid field in AMI.
63
     */
64
    private $id;
65
66
    /**
67
     * @var string Name of the channel (i.e. SIP/foo-0000a7e3)
68
     */
69
    private $name;
70
71
    /**
72
     * @var string
73
     */
74
    private $state;
75
76
    /**
77
     * @return string
78
     */
79
    public function getAccountCode()
80
    {
81
        return $this->accountCode;
82
    }
83
84
    /**
85
     * @return CallerId Caller identification
86
     */
87
    public function getCaller()
88
    {
89
        return $this->caller;
90
    }
91
92
    /**
93
     * @return CallerId Connected caller identification
94
     */
95
    public function getConnected()
96
    {
97
        return $this->connected;
98
    }
99
100
    /**
101
     * @return DateTime
102
     */
103
    public function getCreationTime()
104
    {
105
        return $this->creationTime;
106
    }
107
108
    /**
109
     * @return DialplanCep Dialplan location (context/extension/priority)
110
     */
111 1
    public function getDialplan()
112
    {
113 1
        return $this->dialplan;
114
    }
115
116
    /**
117
     * @return string Unique identifier of the channel.  This is the same as the Uniqueid field in AMI.
118
     */
119 37
    public function getId()
120
    {
121 37
        return $this->id;
122
    }
123
124
    /**
125
     * @return string Name of the channel (i.e. SIP/foo-0000a7e3)
126
     */
127
    public function getName()
128
    {
129
        return $this->name;
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getState()
136
    {
137
        return $this->state;
138
    }
139
140
    /**
141
     * @param callable $callback
142
     */
143
    public function onStasisEnd(callable $callback)
144
    {
145
        $this->on(Event::STASIS_END.'_'.$this->getId(), $callback);
146
    }
147
148
    /**
149
     * @param callable $callback
150
     */
151
    public function onceStasisEnd(callable $callback)
152
    {
153
        $this->once(Event::STASIS_END.'_'.$this->getId(), $callback);
154
    }
155
156
    /**
157
     * @param callable $callback
158
     */
159
    public function onStasisStart(callable $callback)
160
    {
161
        $this->on(Event::STASIS_START.'_'.$this->getId(), $callback);
162
    }
163
164
    /**
165
     * @param callable $callback
166
     */
167
    public function onceStasisStart(callable $callback)
168
    {
169
        $this->once(Event::STASIS_START.'_'.$this->getId(), $callback);
170
    }
171
172
    /**
173
     * @param callable $callback
174
     */
175
    public function onChannelCallerId(callable $callback)
176
    {
177
        $this->on(Event::CHANNEL_CALLER_ID.'_'.$this->getId(), $callback);
178
    }
179
180
    /**
181
     * @param callable $callback
182
     */
183
    public function onceChannelCallerId(callable $callback)
184
    {
185
        $this->once(Event::CHANNEL_CALLER_ID.'_'.$this->getId(), $callback);
186
    }
187
188
    /**
189
     * @param callable $callback
190
     */
191
    public function onChannelCreated(callable $callback)
192
    {
193
        $this->on(Event::CHANNEL_CREATED.'_'.$this->getId(), $callback);
194
    }
195
196
    /**
197
     * @param callable $callback
198
     */
199
    public function onceChannelCreated(callable $callback)
200
    {
201
        $this->once(Event::CHANNEL_CREATED.'_'.$this->getId(), $callback);
202
    }
203
204
    /**
205
     * @param callable $callback
206
     */
207
    public function onChannelDestroyed(callable $callback)
208
    {
209
        $this->on(Event::CHANNEL_DESTROYED.'_'.$this->getId(), $callback);
210
    }
211
212
    /**
213
     * @param callable $callback
214
     */
215
    public function onceChannelDestroyed(callable $callback)
216
    {
217
        $this->once(Event::CHANNEL_DESTROYED.'_'.$this->getId(), $callback);
218
    }
219
220
    /**
221
     * @param callable $callback
222
     */
223
    public function removeChannelDestroyedListener(callable $callback)
224
    {
225
        $this->removeListener(Event::CHANNEL_DESTROYED.'_'.$this->getId(), $callback);
226
    }
227
228
    /**
229
     * @param callable $callback
230
     */
231
    public function onChannelDtmfReceived(callable $callback)
232
    {
233
        $this->on(Event::CHANNEL_DTMF_RECEIVED.'_'.$this->getId(), $callback);
234
    }
235
236
    /**
237
     * @param callable $callback
238
     */
239
    public function onceChannelDtmfReceived(callable $callback)
240
    {
241
        $this->once(Event::CHANNEL_DTMF_RECEIVED.'_'.$this->getId(), $callback);
242
    }
243
244
    /**
245
     * @param callable $callback
246
     */
247
    public function onChannelEnteredBridge(callable $callback)
248
    {
249
        $this->on(Event::CHANNEL_ENTERED_BRIDGE.'_'.$this->getId(), $callback);
250
    }
251
252
    /**
253
     * @param callable $callback
254
     */
255
    public function onceChannelEnteredBridge(callable $callback)
256
    {
257
        $this->once(Event::CHANNEL_ENTERED_BRIDGE.'_'.$this->getId(), $callback);
258
    }
259
260
    /**
261
     * @param callable $callback
262
     */
263
    public function onChannelHangupRequest(callable $callback)
264
    {
265
        $this->on(Event::CHANNEL_HANGUP_REQUEST.'_'.$this->getId(), $callback);
266
    }
267
268
    /**
269
     * @param callable $callback
270
     */
271
    public function onceChannelHangupRequest(callable $callback)
272
    {
273
        $this->once(Event::CHANNEL_HANGUP_REQUEST.'_'.$this->getId(), $callback);
274
    }
275
276
    /**
277
     * @param callable $callback
278
     */
279
    public function onChannelLeftBridge(callable $callback)
280
    {
281
        $this->on(Event::CHANNEL_LEFT_BRIDGE.'_'.$this->getId(), $callback);
282
    }
283
284
    /**
285
     * @param callable $callback
286
     */
287
    public function onceChannelLeftBridge(callable $callback)
288
    {
289
        $this->once(Event::CHANNEL_LEFT_BRIDGE.'_'.$this->getId(), $callback);
290
    }
291
292
    /**
293
     * @param callable $callback
294
     */
295
    public function onChannelStateChange(callable $callback)
296
    {
297
        $this->on(Event::CHANNEL_STATE_CHANGED.'_'.$this->getId(), $callback);
298
    }
299
300
    /**
301
     * @param callable $callback
302
     */
303
    public function onceChannelStateChange(callable $callback)
304
    {
305
        $this->once(Event::CHANNEL_STATE_CHANGED.'_'.$this->getId(), $callback);
306
    }
307
308
    /**
309
     * @param callable $callback
310
     */
311
    public function onChannelTalkingFinished(callable $callback)
312
    {
313
        $this->on(Event::CHANNEL_TALKING_FINISHED.'_'.$this->getId(), $callback);
314
    }
315
316
    /**
317
     * @param callable $callback
318
     */
319
    public function onceChannelTalkingFinished(callable $callback)
320
    {
321
        $this->once(Event::CHANNEL_TALKING_FINISHED.'_'.$this->getId(), $callback);
322
    }
323
324
    /**
325
     * @param callable $callback
326
     */
327
    public function onChannelTalkingStarted(callable $callback)
328
    {
329
        $this->on(Event::CHANNEL_TALKING_STARTED.'_'.$this->getId(), $callback);
330
    }
331
332
    /**
333
     * @param callable $callback
334
     */
335
    public function onceChannelTalkingStarted(callable $callback)
336
    {
337
        $this->once(Event::CHANNEL_TALKING_STARTED.'_'.$this->getId(), $callback);
338
    }
339
340
    /**
341
     * @param callable $callback
342
     */
343
    public function onChannelUserevent(callable $callback)
344
    {
345
        $this->on(Event::CHANNEL_USEREVENT.'_'.$this->getId(), $callback);
346
    }
347
348
    /**
349
     * @param callable $callback
350
     */
351
    public function onceChannelUserevent(callable $callback)
352
    {
353
        $this->once(Event::CHANNEL_USEREVENT.'_'.$this->getId(), $callback);
354
    }
355
356
    /**
357
     * @param callable $callback
358
     */
359
    public function onChannelVarset(callable $callback)
360
    {
361
        $this->on(Event::CHANNEL_VARSET.'_'.$this->getId(), $callback);
362
    }
363
364
    /**
365
     * @param callable $callback
366
     */
367
    public function onceChannelVarset(callable $callback)
368
    {
369
        $this->once(Event::CHANNEL_VARSET.'_'.$this->getId(), $callback);
370
    }
371
372
    /**
373
     * Delete (i.e. hangup) a channel.
374
     *
375
     * @throws NotFoundException
376
     */
377
    public function deleteChannel()
378
    {
379
        $this->client->channels()->deleteChannel($this->id);
380
    }
381
382
    /**
383
     * Hangup the channel if it still exists.
384
     */
385 1
    public function hangup()
386
    {
387 1
        $this->client->channels()->hangup($this->id);
388 1
    }
389
390
    /**
391
     * Exit application; continue execution in the dialplan.
392
     *
393
     * @param string $context The context to continue to.
394
     * @param string $extension The extension to continue to.
395
     * @param int $priority The priority to continue to.
396
     * @throws NotFoundException
397
     * @throws ConflictException
398
     */
399
    public function continueDialplan($context, $extension, $priority)
400
    {
401
        $this->client->channels()->continueDialplan($this->id, $context, $extension, $priority);
402
    }
403
404
    /**
405
     * Answer a channel.
406
     *
407
     * @throws NotFoundException
408
     * @throws ConflictException
409
     */
410 36
    public function answer()
411
    {
412 36
        $this->client->channels()->answer($this->id);
413 36
    }
414
415
    /**
416
     * Indicate ringing to a channel.
417
     *
418
     * @throws NotFoundException
419
     * @throws ConflictException
420
     */
421
    public function startRinging()
422
    {
423
        $this->client->channels()->startRinging($this->id);
424
    }
425
426
    /**
427
     * Stop ringing indication on a channel if locally generated.
428
     *
429
     * @throws NotFoundException
430
     * @throws ConflictException
431
     */
432
    public function stopRinging()
433
    {
434
        $this->client->channels()->stopRinging($this->id);
435
    }
436
437
    /**
438
     * Send provided DTMF to a given channel.
439
     *
440
     * @param string $dtmf DTMF To send.
441
     * @param int $before Amount of time to wait before DTMF digits (specified in milliseconds) start.
442
     * @param int $between Amount of time in between DTMF digits (specified in milliseconds).  Default: 100
443
     * @param int $duration Length of each DTMF digit (specified in milliseconds).  Default: 100
444
     * @param int $after Amount of time to wait after DTMF digits (specified in milliseconds) end.
445
     * @throws InvalidParameterException
446
     * @throws NotFoundException
447
     * @throws ConflictException
448
     */
449
    public function sendDtmf($dtmf, $before = null, $between = null, $duration = null, $after = null)
450
    {
451
        $this->client->channels()->sendDtmf($this->id, $dtmf, $before, $between, $duration, $after);
452
    }
453
454
    /**
455
     * Mute a channel.
456
     *
457
     * @param string $direction (default both) Direction in which to mute audio
458
     * @throws NotFoundException
459
     * @throws ConflictException
460
     */
461
    public function mute($direction)
462
    {
463
        $this->client->channels()->mute($this->id, $direction);
464
    }
465
466
    /**
467
     * Unmute a channel.
468
     *
469
     * @param string $direction (default both) Direction in which to unmute audio
470
     * @throws NotFoundException
471
     * @throws ConflictException
472
     */
473
    public function unmute($direction)
474
    {
475
        $this->client->channels()->unmute($this->id, $direction);
476
    }
477
478
    /**
479
     * Hold a channel.
480
     *
481
     * @throws NotFoundException
482
     * @throws ConflictException
483
     */
484
    public function hold()
485
    {
486
        $this->client->channels()->hold($this->id);
487
    }
488
489
    /**
490
     * Remove a channel from hold.
491
     *
492
     * @throws NotFoundException
493
     * @throws ConflictException
494
     */
495
    public function unhold()
496
    {
497
        $this->client->channels()->unhold($this->id);
498
    }
499
500
    /**
501
     * Play music on hold to a channel. Using media operations such as /play on a channel playing MOH in
502
     * this manner will suspend MOH without resuming automatically. If continuing music on hold is
503
     * desired, the stasis application must reinitiate music on hold.
504
     *
505
     * @param string $mohClass Music on hold class to use
506
     * @throws NotFoundException
507
     * @throws ConflictException
508
     */
509
    public function startMusicOnHold($mohClass)
510
    {
511
        $this->client->channels()->startMusicOnHold($this->id, $mohClass);
512
    }
513
514
    /**
515
     * Stop playing music on hold to a channel.
516
     *
517
     * @throws NotFoundException
518
     * @throws ConflictException
519
     */
520
    public function stopMusicOnHold()
521
    {
522
        $this->client->channels()->stopMusicOnHold($this->id);
523
    }
524
525
    /**
526
     * 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.
527
     *
528
     * @throws NotFoundException
529
     * @throws ConflictException
530
     */
531
    public function startSilence()
532
    {
533
        $this->client->channels()->startSilence($this->id);
534
    }
535
536
    /**
537
     * Stop playing silence to a channel.
538
     *
539
     * @throws NotFoundException
540
     * @throws ConflictException
541
     */
542
    public function stopSilence()
543
    {
544
        $this->client->channels()->stopSilence($this->id);
545
    }
546
547
    /**
548
     * Start playback of media. The media URI may be any of a number of URI's. Currently sound:,
549
     * recording:, number:, digits:, characters:, and tone: URI's are supported. This operation creates a
550
     * playback resource that can be used to control the playback of media (pause, rewind, fast forward,
551
     * etc.)
552
     *
553
     * @link https://wiki.asterisk.org/wiki/display/AST/ARI+and+Channels%3A+Simple+Media+Manipulation Simple media playback
554
     *
555
     * @param string $media (required) Media's URI to play.
556
     * @param string $lang For sounds, selects language for sound.
557
     * @param int $offsetms Number of media to skip before playing.
558
     * @param int $skipms (3000 default) Number of milliseconds to skip for forward/reverse operations.
559
     * @param string $playbackId Playback Id.
560
     * @return Playback
561
     * @throws NotFoundException
562
     * @throws ConflictException
563
     */
564 2
    public function playMedia($media, $lang = null, $offsetms = null, $skipms = null, $playbackId = null)
565
    {
566 2
        return $this->client->channels()->playMedia($this->id, $media, $lang, $offsetms, $skipms, $playbackId);
567
    }
568
569
    /**
570
     * Start playback of media and specify the playbackId. The media URI may be any of a number of URI's.
571
     * Currently sound: and recording: URI's are supported. This operation creates a playback resource
572
     * that can be used to control the playback of media (pause, rewind, fast forward, etc.)
573
     *
574
     * @link https://wiki.asterisk.org/wiki/display/AST/ARI+and+Channels%3A+Simple+Media+Manipulation Simple media playback
575
     *
576
     * @param string $media (required) Media's URI to play.
577
     * @param string $lang For sounds, selects language for sound.
578
     * @param int $offsetms Number of media to skip before playing.
579
     * @param int $skipms (3000 default) Number of milliseconds to skip for forward/reverse operations.
580
     * @param string $playbackId Playback Id.
581
     * @return Playback
582
     * @throws NotFoundException
583
     * @throws ConflictException
584
     */
585 4
    public function playMediaWithId($media, $lang = null, $offsetms = null, $skipms = null, $playbackId = null)
586
    {
587 4
        return $this->client->channels()->playMediaWithId($this->getId(), $media, $lang, $offsetms, $skipms,
588 4
            $playbackId);
589
    }
590
591
    /**
592
     * Start a recording. Record audio from a channel. Note that this will not capture audio sent to the
593
     * channel. The bridge itself has a record feature if that's what you want.
594
     *
595
     * @param string $name (required) Recording's filename
596
     * @param string $format (required) Format to encode audio in
597
     * @param int $maxDurationSeconds Maximum duration of the recording, in seconds. 0 for no limit.  Allowed range: Min: 0; Max: None
598
     * @param int $maxSilenceSeconds Maximum duration of silence, in seconds. 0 for no limit.  Allowed range: Min: 0; Max: None
599
     * @param string $ifExists = Action to take if a recording with the same name already exists. default: fail, Allowed values: fail, overwrite, append
600
     * @param boolean $beep Play beep when recording begins
601
     * @param string $terminateOn DTMF input to terminate recording.  Default: none, Allowed values: none, any, *, #
602
     * @return LiveRecording
603
     * @throws InvalidParameterException
604
     * @throws NotFoundException
605
     * @throws ConflictException
606
     * @throws UnprocessableEntityException
607
     */
608 View Code Duplication
    public function record(
0 ignored issues
show
Duplication introduced by
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...
609
        $name,
610
        $format,
611
        $maxDurationSeconds = null,
612
        $maxSilenceSeconds = null,
613
        $ifExists = null,
614
        $beep = null,
615
        $terminateOn = null
616
    ) {
617
        return $this->client->channels()->record($this->id, $name, $format, $maxDurationSeconds, $maxSilenceSeconds,
618
            $ifExists, $beep, $terminateOn);
619
    }
620
621
    /**
622
     * Get the value of a channel variable or function.
623
     *
624
     * @param string $variable
625
     * @return string|Variable
626
     * @throws InvalidParameterException
627
     * @throws NotFoundException
628
     * @throws ConflictException
629
     */
630
    public function getVariable($variable)
631
    {
632
        return $this->client->channels()->getVariable($this->id, $variable);
633
    }
634
635
    /**
636
     * Set the value of a channel variable or function.
637
     *
638
     * @param string $variable
639
     * @param string $value
640
     * @return Variable
641
     * @throws InvalidParameterException
642
     * @throws NotFoundException
643
     * @throws ConflictException
644
     */
645
    public function setVariable($variable, $value)
646
    {
647
        return $this->client->channels()->setVariable($this->id, $variable, $value);
648
    }
649
650
    /**
651
     * Start snooping. Snoop (spy/whisper) on a specific channel.
652
     *
653
     * @param string $spy (default none) Direction of audio to spy on
654
     * @param string $whisper (default none) Direction of audio to whisper into
655
     * @param string $app (required) Application the snooping channel is placed into
656
     * @param string $appArgs The application arguments to pass to the Stasis application
657
     * @param string $snoopId Unique ID to assign to snooping channel
658
     * @return Channel
659
     * @throws InvalidParameterException
660
     * @throws NotFoundException
661
     */
662
    public function startSnoop($spy, $whisper, $app, $appArgs, $snoopId)
663
    {
664
        return $this->client->channels()->startSnoop($this->id, $spy, $whisper, $app, $appArgs, $snoopId);
665
    }
666
667
    /**
668
     * Start snooping. Snoop (spy/whisper) on a specific channel.
669
     *
670
     * @param string $spy (default none) Direction of audio to spy on
671
     * @param string $whisper (default none) Direction of audio to whisper into
672
     * @param string $app (required) Application the snooping channel is placed into
673
     * @param string $appArgs The application arguments to pass to the Stasis application
674
     * @param string $snoopId Unique ID to assign to snooping channel
675
     * @return Channel
676
     * @throws InvalidParameterException
677
     * @throws NotFoundException
678
     */
679
    public function startSnoopWithId($spy, $whisper, $app, $appArgs, $snoopId)
680
    {
681
        return $this->client->channels()->startSnoopWithId($this->id, $spy, $whisper, $app, $appArgs, $snoopId);
682
    }
683
684
    /**
685
     * @param AriClient $client
686
     * @param string $response
687
     */
688 37
    public function __construct(AriClient $client, $response)
689
    {
690 37
        parent::__construct($client, $response);
691
692 37
        $this->accountCode = property_exists($this->response, 'account_code') ? $this->response->account_code : null;
693 37
        $this->caller = new CallerId($this->response->caller);
694 37
        $this->connected = new CallerId($this->response->connected);
695 37
        $this->creationTime = new \DateTime($this->response->creationtime);
696 37
        $this->dialplan = new DialplanCep($this->response->dialplan);
697 37
        $this->id = $this->response->id;
698 37
        $this->name = $this->response->name;
699 37
        $this->state = $this->response->state;
700 37
    }
701
702
}
703