1515use Vonage \Voice \Endpoint \EndpointInterface ;
1616use Vonage \Voice \Endpoint \Phone ;
1717use Vonage \Voice \NCCO \NCCO ;
18+ use Vonage \Voice \VoiceObjects \AdvancedMachineDetection ;
1819
1920class OutboundCall
2021{
2122 public const MACHINE_CONTINUE = 'continue ' ;
2223 public const MACHINE_HANGUP = 'hangup ' ;
23-
24- /**
25- * @var Webhook
26- */
27- protected $ answerWebhook ;
28-
29- /**
30- * @var Webhook
31- */
32- protected $ eventWebhook ;
24+ protected ?Webhook $ answerWebhook = null ;
25+ protected ?Webhook $ eventWebhook = null ;
3326
3427 /**
3528 * Length of seconds before Vonage hangs up after going into `in_progress` status
36- *
37- * @var int
3829 */
39- protected $ lengthTimer ;
30+ protected int $ lengthTimer = 7200 ;
4031
4132 /**
4233 * What to do when Vonage detects an answering machine.
43- *
44- * @var ?string
4534 */
46- protected $ machineDetection ;
35+ protected ?string $ machineDetection = '' ;
36+
4737 /**
48- * @var NCCO
38+ * Overrides machine detection if used for more configuration options
4939 */
50- protected $ ncco ;
40+ protected ?AdvancedMachineDetection $ advancedMachineDetection = null ;
41+
42+ protected ?NCCO $ ncco = null ;
5143
5244 /**
53- * Whether or not to use random numbers linked on the application
54- *
55- * @var bool
45+ * Whether to use random numbers linked on the application
5646 */
57- protected $ randomFrom = false ;
47+ protected bool $ randomFrom = false ;
5848
5949 /**
6050 * Length of time Vonage will allow a phone number to ring before hanging up
61- *
62- * @var int
6351 */
64- protected $ ringingTimer ;
52+ protected int $ ringingTimer = 60 ;
6553
6654 /**
6755 * Creates a new Outbound Call object
6856 * If no `$from` parameter is passed, the system will use a random number
6957 * that is linked to the application instead.
70- *
71- *
72- * @return void
7358 */
7459 public function __construct (protected EndpointInterface $ to , protected ?Phone $ from = null )
7560 {
@@ -118,39 +103,27 @@ public function getTo(): EndpointInterface
118103 return $ this ->to ;
119104 }
120105
121- /**
122- * @return $this
123- */
124106 public function setAnswerWebhook (Webhook $ webhook ): self
125107 {
126108 $ this ->answerWebhook = $ webhook ;
127109
128110 return $ this ;
129111 }
130112
131- /**
132- * @return $this
133- */
134113 public function setEventWebhook (Webhook $ webhook ): self
135114 {
136115 $ this ->eventWebhook = $ webhook ;
137116
138117 return $ this ;
139118 }
140119
141- /**
142- * @return $this
143- */
144120 public function setLengthTimer (int $ timer ): self
145121 {
146122 $ this ->lengthTimer = $ timer ;
147123
148124 return $ this ;
149125 }
150126
151- /**
152- * @return $this
153- */
154127 public function setMachineDetection (string $ action ): self
155128 {
156129 if ($ action === self ::MACHINE_CONTINUE || $ action === self ::MACHINE_HANGUP ) {
@@ -162,19 +135,13 @@ public function setMachineDetection(string $action): self
162135 throw new InvalidArgumentException ('Unknown machine detection action ' );
163136 }
164137
165- /**
166- * @return $this
167- */
168138 public function setNCCO (NCCO $ ncco ): self
169139 {
170140 $ this ->ncco = $ ncco ;
171141
172142 return $ this ;
173143 }
174144
175- /**
176- * @return $this
177- */
178145 public function setRingingTimer (int $ timer ): self
179146 {
180147 $ this ->ringingTimer = $ timer ;
@@ -186,4 +153,16 @@ public function getRandomFrom(): bool
186153 {
187154 return $ this ->randomFrom ;
188155 }
156+
157+ public function getAdvancedMachineDetection (): ?AdvancedMachineDetection
158+ {
159+ return $ this ->advancedMachineDetection ;
160+ }
161+
162+ public function setAdvancedMachineDetection (?AdvancedMachineDetection $ advancedMachineDetection ): static
163+ {
164+ $ this ->advancedMachineDetection = $ advancedMachineDetection ;
165+
166+ return $ this ;
167+ }
189168}
0 commit comments