Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit 65eea09

Browse files
authored
Merge pull request #2 from mobtexting/master
rebase with team
2 parents 92a018d + a881a87 commit 65eea09

4 files changed

Lines changed: 71 additions & 14 deletions

File tree

example/dial.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
require(__DIR__.'/../vendor/autoload.php');
3+
4+
$response = new Mobtexting\Voice();
5+
$response->answer();
6+
$dial = $response->dial("+91720414xxxx", "+91803007xxxx"); // customer number, DID number
7+
$dial->onNoAnswer("dial", array("+9172xxxx", "+9180xxxx")); // customer number, DID number
8+
9+
10+
//print_r($response->toArray());
11+
12+
echo $response;

src/Voice/Tag/Dial.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,37 @@ public function __construct($to, $from = null)
1717
parent::__construct("Dial", $attrib);
1818
}
1919

20-
public function onAnswer($tag, $attribs = [])
20+
public function onAnswer($tag, $attribs = [], $isSequential = false)
2121
{
22-
return $this->setAttribute('onanswer', $this->append($tag, $attribs), true);
22+
$newTag = $this->append($tag, $attribs);
23+
if($isSequential){
24+
$this->attributes['onanswer'] = array_merge($this->attributes['onanswer'], array($newTag) );
25+
}else {
26+
$this->setAttribute('onanswer', array($newTag), true);
27+
}
28+
return $newTag;
2329
}
2430

25-
public function onNoAnswer($tag, $attribs = [])
31+
public function onNoAnswer($tag, $attribs = [], $isSequential = false)
2632
{
27-
return $this->setAttribute('onnoanswer', $this->append($tag, $attribs), true);
33+
$newTag = $this->append($tag, $attribs);
34+
if($isSequential){
35+
$this->attributes['onnoanswer'] = array_merge($this->attributes['onnoanswer'], array($newTag) );
36+
}else {
37+
$this->setAttribute('onnoanswer', array($newTag), true);
38+
}
39+
return $newTag;
2840
}
2941

30-
public function noAnswer($tag, $attribs = [])
42+
public function noAnswer($tag, $attribs = [], $isSequential = false)
3143
{
32-
return $this->setAttribute('onnoanswer', $this->append($tag, $attribs), true);
44+
$newTag = $this->append($tag, $attribs);
45+
if($isSequential){
46+
$this->attributes['onnoanswer'] = array_merge($this->attributes['onnoanswer'], array($newTag) );
47+
}else {
48+
$this->setAttribute('onnoanswer', array($newTag), true);
49+
}
50+
return $newTag;
3351
}
3452

3553
public function getDefaultAttributes()

src/Voice/Tag/Filter.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,28 @@ public function __construct($data = null, $type = 'frequency')
3030
parent::__construct("Filter", ['type' => $type, $unit => $data]);
3131
}
3232

33-
public function onFail($tag, $attribs = [])
33+
public function onFail($tag, $attribs = [], $isSequential = false)
3434
{
35-
return $this->setAttribute('onfail', $this->append($tag, $attribs), true);
35+
$newTag = $this->append($tag, $attribs);
36+
if($isSequential){
37+
$this->attributes['onfail'] = array_merge($this->attributes['onfail'], array($newTag) );
38+
}else {
39+
$this->setAttribute('onfail', array($newTag), true);
40+
}
41+
42+
return $newTag;
3643
}
3744

38-
public function onPass($tag, $attribs = [])
45+
public function onPass($tag, $attribs = [], $isSequential = false)
3946
{
40-
return $this->setAttribute('onpass', $this->append($tag, $attribs), true);
47+
$newTag = $this->append($tag, $attribs);
48+
if($isSequential){
49+
$this->attributes['onpass'] = array_merge($this->attributes['onpass'], array($newTag) );
50+
}else {
51+
$this->setAttribute('onpass', array($newTag), true);
52+
}
53+
54+
return $newTag;
4155
}
4256

4357
public function getDefaultAttributes()

src/Voice/Tag/Menu.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,27 @@ public function __construct($prompt, $attribs = [])
1818
parent::__construct("Menu", $attribs);
1919
}
2020

21-
public function onFail($verb, $attribs = [])
21+
public function onFail($verb, $attribs = [], $isSequential = false)
2222
{
23-
return $this->setAttribute('onFail', $this->append($verb, $attribs), true);
23+
$newTag = $this->append($verb, $attribs);
24+
if($isSequential){
25+
$this->attributes['onfail'] = array_merge($this->attributes['onfail'], array($newTag) );
26+
}else {
27+
$this->setAttribute('onfail', array($newTag), true);
28+
}
29+
return $newTag;
2430
}
2531

26-
public function onTimeout($verb, $attribs = [])
32+
public function onTimeout($verb, $attribs = [], $isSequential = false)
2733
{
28-
return $this->setAttribute('timeout', $this->append($verb, $attribs), true);
34+
$newTag = $this->append($verb, $attribs);
35+
if($isSequential){
36+
$this->attributes['timeout'] = array_merge($this->attributes['timeout'], array($newTag) );
37+
}else {
38+
$this->setAttribute('timeout', array($newTag), true);
39+
}
40+
41+
return $newTag;
2942
}
3043

3144
public function getDefaultAttributes()

0 commit comments

Comments
 (0)