-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from Bandwidth/DX-2467
DX-2467 added modifyCallBxml function
- Loading branch information
Showing
3 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Bxml.php | ||
* | ||
* Class that represents the BXML response. Is built by adding verbs to it | ||
* | ||
* * @copyright Bandwidth INC | ||
*/ | ||
|
||
namespace BandwidthLib\Voice\Bxml; | ||
|
||
use DOMDocument; | ||
|
||
class Bxml { | ||
|
||
/** | ||
* Creates the Bxml class with an empty list of verbs | ||
*/ | ||
public function __construct() { | ||
$this->verbs = array(); | ||
} | ||
|
||
/** | ||
* Adds the verb to the verbs | ||
* | ||
* @param Verb $verb The verb to add to the list | ||
*/ | ||
public function addVerb($verb) { | ||
array_push($this->verbs, $verb); | ||
} | ||
|
||
/** | ||
* Converts the Response class into its BXML representation | ||
* | ||
* @return string The xml representation of the class | ||
*/ | ||
public function toBxml() { | ||
$ssmlRegex = '/<([a-zA-Z\/\/].*?)>/'; | ||
$doc = new DOMDocument('1.0', 'UTF-8'); | ||
$bxmlElement = $doc->createElement("Bxml"); | ||
|
||
foreach ($this->verbs as $verb) { | ||
$bxmlElement->appendChild($verb->toBxml($doc)); | ||
} | ||
|
||
$doc->appendChild($bxmlElement); | ||
return str_replace("\n", '', preg_replace($ssmlRegex, "<$1>", $doc->saveXML())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters