Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ try {

```php

$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence("Hello!");
$speakSentence->voice("susan");
$speakSentence->locale("en_US");
$speakSentence->gender("female");
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($speakSentence);
$speakSentence = BandwidthLib\Voice\Bxml\SpeakSentence::make("Hello!")
->voice("susan")
->locale("en_US")
->gender("female");
$response = BandwidthLib\Voice\Bxml\Response::make()
->addVerb($speakSentence);
echo $response->toBxml();
```

Expand Down
42 changes: 28 additions & 14 deletions src/Voice/Bxml/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace BandwidthLib\Voice\Bxml;

use DOMDocument;
use DOMElement;

require_once "Verb.php";

Expand Down Expand Up @@ -85,119 +86,132 @@ public function __construct(string $targetCall) {
*
* @param string $bridgeCompleteUrl URL to send the bridge complete event to
*/
public function bridgeCompleteUrl(string $bridgeCompleteUrl) {
public function bridgeCompleteUrl(string $bridgeCompleteUrl): Bridge {
$this->bridgeCompleteUrl = $bridgeCompleteUrl;
return $this;
}

/**
* Sets the bridgeCompleteMethod attribute for Bridge
*
* @param string $bridgeCompleteMethod HTTP method to send the bridge complete event
*/
public function bridgeCompleteMethod(string $bridgeCompleteMethod) {
public function bridgeCompleteMethod(string $bridgeCompleteMethod): Bridge {
$this->bridgeCompleteMethod = $bridgeCompleteMethod;
return $this;
}

/**
* Sets the bridgeTargetCompleteUrl attribute for Bridge
*
* @param string $bridgeTargetCompleteUrl URL to send the bridge target complete event to
*/
public function bridgeTargetCompleteUrl(string $bridgeTargetCompleteUrl) {
public function bridgeTargetCompleteUrl(string $bridgeTargetCompleteUrl): Bridge {
$this->bridgeTargetCompleteUrl = $bridgeTargetCompleteUrl;
return $this;
}

/**
* Sets the bridgeTargetCompleteMethod attribute for Bridge
*
* @param string $bridgeTargetCompleteMethod HTTP method to send the bridge target complete event
*/
public function bridgeTargetCompleteMethod(string $bridgeTargetCompleteMethod) {
public function bridgeTargetCompleteMethod(string $bridgeTargetCompleteMethod): Bridge {
$this->bridgeTargetCompleteMethod = $bridgeTargetCompleteMethod;
return $this;
}

/**
* Sets the username attribute for Bridge
*
* @param string $username HTTP basic auth username for sending events
*/
public function username(string $username) {
public function username(string $username): Bridge {
$this->username = $username;
return $this;
}

/**
* Sets the password attribute for Bridge
*
* @param string $password HTTP basic auth password for sending events
*/
public function password(string $password) {
public function password(string $password): Bridge {
$this->password = $password;
return $this;
}

/**
* Sets the tag attribute for Bridge
*
* @param string $tag String to include in events
*/
public function tag(string $tag) {
public function tag(string $tag): Bridge {
$this->tag = $tag;
return $this;
}

/**
* Sets the bridgeCompleteFallbackUrl attribute for Bridge
*
* @param string $bridgeCompleteFallbackUrl Fallback URL for bridge complete callback events
*/
public function bridgeCompleteFallbackUrl(string $bridgeCompleteFallbackUrl) {
public function bridgeCompleteFallbackUrl(string $bridgeCompleteFallbackUrl): Bridge {
$this->bridgeCompleteFallbackUrl = $bridgeCompleteFallbackUrl;
return $this;
}

/**
* Sets the bridgeCompleteFallbackMethod attribute for Bridge
*
* @param string $bridgeCompleteFallbackMethod HTTP method for bridge complete fallback requests
*/
public function bridgeCompleteFallbackMethod(string $bridgeCompleteFallbackMethod) {
public function bridgeCompleteFallbackMethod(string $bridgeCompleteFallbackMethod): Bridge {
$this->bridgeCompleteFallbackMethod = $bridgeCompleteFallbackMethod;
return $this;
}

/**
* Sets the bridgeTargetCompleteFallbackUrl attribute for Bridge
*
* @param string $bridgeTargetCompleteFallbackUrl Fallback URL for bridge target complete callback events
*/
public function bridgeTargetCompleteFallbackUrl(string $bridgeTargetCompleteFallbackUrl) {
public function bridgeTargetCompleteFallbackUrl(string $bridgeTargetCompleteFallbackUrl): Bridge {
$this->bridgeTargetCompleteFallbackUrl = $bridgeTargetCompleteFallbackUrl;
return $this;
}

/**
* Sets the bridgeTargetCompleteFallbackMethod attribute for Bridge
*
* @param string $bridgeTargetCompleteFallbackMethod HTTP method for bridge target complete fallback events
*/
public function bridgeTargetCompleteFallbackMethod(string $bridgeTargetCompleteFallbackMethod) {
public function bridgeTargetCompleteFallbackMethod(string $bridgeTargetCompleteFallbackMethod): Bridge {
$this->bridgeTargetCompleteFallbackMethod = $bridgeTargetCompleteFallbackMethod;
return $this;
}

/**
* Sets the fallbackUsername attribute for Bridge
*
* @param string $fallbackUsername HTTP basic auth username for fallback events
*/
public function fallbackUsername(string $fallbackUsername) {
public function fallbackUsername(string $fallbackUsername): Bridge {
$this->fallbackUsername = $fallbackUsername;
return $this;
}

/**
* Sets the fallbackPassword attribute for Bridge
*
* @param string $fallbackPassword HTTP basic auth password
*/
public function fallbackPassword(string $fallbackPassword) {
public function fallbackPassword(string $fallbackPassword): Bridge {
$this->fallbackPassword = $fallbackPassword;
return $this;
}

public function toBxml(DOMDocument $doc) {
public function toBxml(DOMDocument $doc): DOMElement {
$element = $doc->createElement("Bridge");

$element->appendChild($doc->createTextNode($this->targetCall));
Expand Down
5 changes: 3 additions & 2 deletions src/Voice/Bxml/Bxml.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ public function __construct() {
*
* @param Verb $verb The verb to add to the list
*/
public function addVerb(Verb $verb) {
public function addVerb(Verb $verb): Bxml {
array_push($this->verbs, $verb);
return $this;
}

/**
* Converts the Response class into its BXML representation
*
* @return string The xml representation of the class
*/
public function toBxml() {
public function toBxml(): string {
$ssmlRegex = '/<([a-zA-Z\/\/].*?)>/';
$doc = new DOMDocument('1.0', 'UTF-8');
$bxmlElement = $doc->createElement("Bxml");
Expand Down
42 changes: 28 additions & 14 deletions src/Voice/Bxml/Conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace BandwidthLib\Voice\Bxml;

use DOMDocument;
use DOMElement;

require_once "Verb.php";

Expand Down Expand Up @@ -81,119 +82,132 @@ public function __construct(string $conferenceName) {
*
* @param string $tag A custom string to be included in callbacks
*/
public function tag(string $tag) {
public function tag(string $tag): Conference {
$this->tag = $tag;
return $this;
}

/**
* Sets the username attribute for Conference
*
* @param string $username Username for basic auth for callbacks
*/
public function username(string $username) {
public function username(string $username): Conference {
$this->username = $username;
return $this;
}

/**
* Sets the password attribute for Conference
*
* @param string $password Password for basic auth for callbacks
*/
public function password(string $password) {
public function password(string $password): Conference {
$this->password = $password;
return $this;
}

/**
* Sets the conferenceEventUrl attribute for Conference
*
* @param string $conferenceEventUrl URL to receive conference events
*/
public function conferenceEventUrl(string $conferenceEventUrl) {
public function conferenceEventUrl(string $conferenceEventUrl): Conference {
$this->conferenceEventUrl = $conferenceEventUrl;
return $this;
}

/**
* Sets the conferenceEventMethod attribute for Conference
*
* @param string $conferenceEventMethod HTTP method for conference events
*/
public function conferenceEventMethod(string $conferenceEventMethod) {
public function conferenceEventMethod(string $conferenceEventMethod): Conference {
$this->conferenceEventMethod = $conferenceEventMethod;
return $this;
}

/**
* Sets the callIdsToCoach attribute for Conference
*
* @param string $callIdsToCoach A string of comma separated call IDs to coach
*/
public function callIdsToCoach(string $callIdsToCoach) {
public function callIdsToCoach(string $callIdsToCoach): Conference {
$this->callIdsToCoach = $callIdsToCoach;
return $this;
}

/**
* Sets the callIdsToCoach attribute for Conference
*
* @param array $callIdsToCoach An array of call IDs to coach
*/
public function callIdsToCoachArray(array $callIdsToCoach) {
public function callIdsToCoachArray(array $callIdsToCoach): Conference {
$this->callIdsToCoach = implode(",", $callIdsToCoach);
return $this;
}

/**
* Sets the mute attribute for Conference
*
* @param boolean $mute Determines if conference members should be on mute
*/
public function mute(bool $mute) {
public function mute(bool $mute): Conference {
$this->mute = $mute;
return $this;
}

/**
* Sets the hold attribute for Conference
*
* @param boolean $hold Determines if conference members should be on hold
*/
public function hold(bool $hold) {
public function hold(bool $hold): Conference {
$this->hold = $hold;
return $this;
}

/**
* Sets the conferenceEventFallbackUrl attribute for Conference
*
* @param string $conferenceEventFallbackUrl Fallback url for conference events
*/
public function conferenceEventFallbackUrl(string $conferenceEventFallbackUrl) {
public function conferenceEventFallbackUrl(string $conferenceEventFallbackUrl): Conference {
$this->conferenceEventFallbackUrl = $conferenceEventFallbackUrl;
return $this;
}

/**
* Sets the conferenceEventFallbackMethod attribute for Conference
*
* @param string $conferenceEventFallbackMethod HTTP method for fallback events
*/
public function conferenceEventFallbackMethod(string $conferenceEventFallbackMethod) {
public function conferenceEventFallbackMethod(string $conferenceEventFallbackMethod): Conference {
$this->conferenceEventFallbackMethod = $conferenceEventFallbackMethod;
return $this;
}

/**
* Sets the fallbackUsername attribute for Conference
*
* @param string $fallbackUsername HTTP basic auth username for fallback events
*/
public function fallbackUsername(string $fallbackUsername) {
public function fallbackUsername(string $fallbackUsername): Conference {
$this->fallbackUsername = $fallbackUsername;
return $this;
}

/**
* Sets the fallbackPassword attribute for Conference
*
* @param string $fallbackPassword HTTP basic auth password for fallback events
*/
public function fallbackPassword(string $fallbackPassword) {
public function fallbackPassword(string $fallbackPassword): Conference {
$this->fallbackPassword = $fallbackPassword;
return $this;
}

public function toBxml(DOMDocument $doc) {
public function toBxml(DOMDocument $doc): DOMElement {
$element = $doc->createElement("Conference");

$element->appendChild($doc->createTextNode($this->conferenceName));
Expand Down
9 changes: 6 additions & 3 deletions src/Voice/Bxml/CustomParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace BandwidthLib\Voice\Bxml;

use DOMDocument;
use DOMElement;

require_once "Verb.php";

Expand All @@ -28,20 +29,22 @@ class CustomParam extends Verb {
*
* @param string $name (required) The name of this parameter, up to 256 characters.
*/
public function name(string $name) {
public function name(string $name): CustomParam {
$this->name = $name;
return $this;
}

/**
* Sets the value attribute for CustomParam
*
* @param string $value (required) The value of this parameter, up to 2048 characters.
*/
public function value(string $value) {
public function value(string $value): CustomParam {
$this->value = $value;
return $this;
}

public function toBxml(DOMDocument $doc) {
public function toBxml(DOMDocument $doc): DOMElement {
$element = $doc->createElement("CustomParam");

if(isset($this->name)) {
Expand Down
Loading