From 14be39806860c225d7ddb123e1d954c51b972a36 Mon Sep 17 00:00:00 2001 From: Ethan Ransdell Date: Wed, 3 Jul 2024 15:45:13 -0400 Subject: [PATCH 1/4] Implement __toString() in Response --- src/Voice/Bxml/Response.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Voice/Bxml/Response.php b/src/Voice/Bxml/Response.php index 3734809..cc6a1a8 100644 --- a/src/Voice/Bxml/Response.php +++ b/src/Voice/Bxml/Response.php @@ -50,4 +50,9 @@ public function toBxml() { $doc->appendChild($responseElement); return str_replace("\n", '', preg_replace($ssmlRegex, "<$1>", $doc->saveXML())); } + + public function __toString() + { + return $this->toBxml(); + } } From 9d792182b1e90c258f1099bccdf1417ef1740d96 Mon Sep 17 00:00:00 2001 From: Ethan Ransdell Date: Wed, 3 Jul 2024 15:45:58 -0400 Subject: [PATCH 2/4] Declare missing $detectLanguage variable --- src/Voice/Bxml/Record.php | 6 +++++- src/Voice/Bxml/StartRecording.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Voice/Bxml/Record.php b/src/Voice/Bxml/Record.php index 57e83a8..ec78d78 100644 --- a/src/Voice/Bxml/Record.php +++ b/src/Voice/Bxml/Record.php @@ -50,6 +50,10 @@ class Record extends Verb { * @var string */ private $fileFormat; + /** + * @var bool + */ + private $detectLanguage; /** * @var int */ @@ -185,7 +189,7 @@ public function fileFormat(string $fileFormat) { * @param boolean $detectLanguage Indicates that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish. */ public function detectLanguage($detectLanguage) { - $this->detectLanguage= $detectLanguage; + $this->detectLanguage = $detectLanguage; } /** diff --git a/src/Voice/Bxml/StartRecording.php b/src/Voice/Bxml/StartRecording.php index 2803cb0..c6460c1 100644 --- a/src/Voice/Bxml/StartRecording.php +++ b/src/Voice/Bxml/StartRecording.php @@ -34,6 +34,10 @@ class StartRecording extends Verb { * @var string */ private $fileFormat; + /** + * @var bool + */ + private $detectLanguage; /** * @var string */ @@ -116,7 +120,7 @@ public function fileFormat(string $fileFormat) { * @param boolean $detectLanguage Indicates that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish. */ public function detectLanguage($detectLanguage) { - $this->detectLanguage= $detectLanguage; + $this->detectLanguage = $detectLanguage; } From 7c559472b7cea90878f46fe13bdd39cc4991149d Mon Sep 17 00:00:00 2001 From: Ethan Ransdell Date: Wed, 3 Jul 2024 16:21:48 -0400 Subject: [PATCH 3/4] Support builder pattern in Voice objects and add types --- src/Voice/Bxml/Bridge.php | 42 ++++++++++++------- src/Voice/Bxml/Bxml.php | 5 ++- src/Voice/Bxml/Conference.php | 42 ++++++++++++------- src/Voice/Bxml/CustomParam.php | 9 ++-- src/Voice/Bxml/Forward.php | 18 +++++--- src/Voice/Bxml/Gather.php | 56 ++++++++++++++++--------- src/Voice/Bxml/Hangup.php | 3 +- src/Voice/Bxml/Pause.php | 6 ++- src/Voice/Bxml/PauseRecording.php | 3 +- src/Voice/Bxml/PhoneNumber.php | 36 ++++++++++------ src/Voice/Bxml/PlayAudio.php | 9 ++-- src/Voice/Bxml/Record.php | 60 ++++++++++++++++++--------- src/Voice/Bxml/Redirect.php | 30 +++++++++----- src/Voice/Bxml/Response.php | 7 ++-- src/Voice/Bxml/ResumeRecording.php | 3 +- src/Voice/Bxml/Ring.php | 9 ++-- src/Voice/Bxml/SendDtmf.php | 9 ++-- src/Voice/Bxml/SipUri.php | 39 +++++++++++------ src/Voice/Bxml/SpeakSentence.php | 12 ++++-- src/Voice/Bxml/StartGather.php | 18 +++++--- src/Voice/Bxml/StartRecording.php | 36 ++++++++++------ src/Voice/Bxml/StartStream.php | 27 ++++++++---- src/Voice/Bxml/StartTranscription.php | 30 +++++++++----- src/Voice/Bxml/StopGather.php | 3 +- src/Voice/Bxml/StopRecording.php | 3 +- src/Voice/Bxml/StopStream.php | 6 ++- src/Voice/Bxml/StopTranscription.php | 6 ++- src/Voice/Bxml/StreamParam.php | 9 ++-- src/Voice/Bxml/Tag.php | 3 +- src/Voice/Bxml/Transfer.php | 51 +++++++++++++++-------- src/Voice/Bxml/Verb.php | 7 ++-- 31 files changed, 395 insertions(+), 202 deletions(-) diff --git a/src/Voice/Bxml/Bridge.php b/src/Voice/Bxml/Bridge.php index 8a1aec7..67e0e43 100644 --- a/src/Voice/Bxml/Bridge.php +++ b/src/Voice/Bxml/Bridge.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -85,8 +86,9 @@ 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; } /** @@ -94,8 +96,9 @@ public function bridgeCompleteUrl(string $bridgeCompleteUrl) { * * @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; } /** @@ -103,8 +106,9 @@ public function bridgeCompleteMethod(string $bridgeCompleteMethod) { * * @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; } /** @@ -112,8 +116,9 @@ public function bridgeTargetCompleteUrl(string $bridgeTargetCompleteUrl) { * * @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; } /** @@ -121,8 +126,9 @@ public function bridgeTargetCompleteMethod(string $bridgeTargetCompleteMethod) { * * @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; } /** @@ -130,8 +136,9 @@ public function username(string $username) { * * @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; } /** @@ -139,8 +146,9 @@ public function password(string $password) { * * @param string $tag String to include in events */ - public function tag(string $tag) { + public function tag(string $tag): Bridge { $this->tag = $tag; + return $this; } /** @@ -148,8 +156,9 @@ public function tag(string $tag) { * * @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; } /** @@ -157,8 +166,9 @@ public function bridgeCompleteFallbackUrl(string $bridgeCompleteFallbackUrl) { * * @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; } /** @@ -166,8 +176,9 @@ public function bridgeCompleteFallbackMethod(string $bridgeCompleteFallbackMetho * * @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; } /** @@ -175,8 +186,9 @@ public function bridgeTargetCompleteFallbackUrl(string $bridgeTargetCompleteFall * * @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; } /** @@ -184,8 +196,9 @@ public function bridgeTargetCompleteFallbackMethod(string $bridgeTargetCompleteF * * @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; } /** @@ -193,11 +206,12 @@ public function fallbackUsername(string $fallbackUsername) { * * @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)); diff --git a/src/Voice/Bxml/Bxml.php b/src/Voice/Bxml/Bxml.php index 6e45adc..a6d4393 100644 --- a/src/Voice/Bxml/Bxml.php +++ b/src/Voice/Bxml/Bxml.php @@ -29,8 +29,9 @@ 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; } /** @@ -38,7 +39,7 @@ public function addVerb(Verb $verb) { * * @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"); diff --git a/src/Voice/Bxml/Conference.php b/src/Voice/Bxml/Conference.php index 60be9a8..c666666 100644 --- a/src/Voice/Bxml/Conference.php +++ b/src/Voice/Bxml/Conference.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -81,8 +82,9 @@ 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; } /** @@ -90,8 +92,9 @@ public function tag(string $tag) { * * @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; } /** @@ -99,8 +102,9 @@ public function username(string $username) { * * @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; } /** @@ -108,8 +112,9 @@ public function password(string $password) { * * @param string $conferenceEventUrl URL to receive conference events */ - public function conferenceEventUrl(string $conferenceEventUrl) { + public function conferenceEventUrl(string $conferenceEventUrl): Conference { $this->conferenceEventUrl = $conferenceEventUrl; + return $this; } /** @@ -117,8 +122,9 @@ public function conferenceEventUrl(string $conferenceEventUrl) { * * @param string $conferenceEventMethod HTTP method for conference events */ - public function conferenceEventMethod(string $conferenceEventMethod) { + public function conferenceEventMethod(string $conferenceEventMethod): Conference { $this->conferenceEventMethod = $conferenceEventMethod; + return $this; } /** @@ -126,8 +132,9 @@ public function conferenceEventMethod(string $conferenceEventMethod) { * * @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; } /** @@ -135,8 +142,9 @@ public function callIdsToCoach(string $callIdsToCoach) { * * @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; } /** @@ -144,8 +152,9 @@ public function callIdsToCoachArray(array $callIdsToCoach) { * * @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; } /** @@ -153,8 +162,9 @@ public function mute(bool $mute) { * * @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; } /** @@ -162,8 +172,9 @@ public function hold(bool $hold) { * * @param string $conferenceEventFallbackUrl Fallback url for conference events */ - public function conferenceEventFallbackUrl(string $conferenceEventFallbackUrl) { + public function conferenceEventFallbackUrl(string $conferenceEventFallbackUrl): Conference { $this->conferenceEventFallbackUrl = $conferenceEventFallbackUrl; + return $this; } /** @@ -171,8 +182,9 @@ public function conferenceEventFallbackUrl(string $conferenceEventFallbackUrl) { * * @param string $conferenceEventFallbackMethod HTTP method for fallback events */ - public function conferenceEventFallbackMethod(string $conferenceEventFallbackMethod) { + public function conferenceEventFallbackMethod(string $conferenceEventFallbackMethod): Conference { $this->conferenceEventFallbackMethod = $conferenceEventFallbackMethod; + return $this; } /** @@ -180,8 +192,9 @@ public function conferenceEventFallbackMethod(string $conferenceEventFallbackMet * * @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; } /** @@ -189,11 +202,12 @@ public function fallbackUsername(string $fallbackUsername) { * * @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)); diff --git a/src/Voice/Bxml/CustomParam.php b/src/Voice/Bxml/CustomParam.php index 5733488..ee2fb6a 100644 --- a/src/Voice/Bxml/CustomParam.php +++ b/src/Voice/Bxml/CustomParam.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -28,8 +29,9 @@ 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; } /** @@ -37,11 +39,12 @@ public function name(string $name) { * * @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)) { diff --git a/src/Voice/Bxml/Forward.php b/src/Voice/Bxml/Forward.php index 6a7b440..18e12a1 100644 --- a/src/Voice/Bxml/Forward.php +++ b/src/Voice/Bxml/Forward.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -40,8 +41,9 @@ class Forward extends Verb { * * @param string $to The phone number to receive the phone call */ - public function to(string $to) { + public function to(string $to): Forward { $this->to = $to; + return $this; } /** @@ -49,8 +51,9 @@ public function to(string $to) { * * @param string $from The phone number to make the phone call */ - public function from(string $from) { + public function from(string $from): Forward { $this->from = $from; + return $this; } /** @@ -58,8 +61,9 @@ public function from(string $from) { * * @param string $callTimeout The timeout in seconds for the phone call */ - public function callTimeout(string $callTimeout) { + public function callTimeout(string $callTimeout): Forward { $this->callTimeout = $callTimeout; + return $this; } /** @@ -67,8 +71,9 @@ public function callTimeout(string $callTimeout) { * * @param string $diversionTreatment The diversion treatment for the phone call */ - public function diversionTreatment(string $diversionTreatment) { + public function diversionTreatment(string $diversionTreatment): Forward { $this->diversionTreatment = $diversionTreatment; + return $this; } /** @@ -76,11 +81,12 @@ public function diversionTreatment(string $diversionTreatment) { * * @param string $diversionReason The diversion treatment for the phone call */ - public function diversionReason(string $diversionReason) { + public function diversionReason(string $diversionReason): Forward { $this->diversionReason = $diversionReason; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Forward"); if(isset($this->to)) { diff --git a/src/Voice/Bxml/Gather.php b/src/Voice/Bxml/Gather.php index b5664c9..4353c5a 100644 --- a/src/Voice/Bxml/Gather.php +++ b/src/Voice/Bxml/Gather.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; require_once "SpeakSentence.php"; @@ -90,8 +91,9 @@ class Gather extends Verb { * * @param string $username The username for http authentication for the gather callback */ - public function username(string $username) { + public function username(string $username): Gather { $this->username = $username; + return $this; } /** @@ -99,8 +101,9 @@ public function username(string $username) { * * @param string $password The password for http authentication for the gather callback */ - public function password(string $password) { + public function password(string $password): Gather { $this->password = $password; + return $this; } /** @@ -108,8 +111,9 @@ public function password(string $password) { * * @param string $gatherUrl The url to receive the gather callback */ - public function gatherUrl(string $gatherUrl) { + public function gatherUrl(string $gatherUrl): Gather { $this->gatherUrl = $gatherUrl; + return $this; } /** @@ -117,8 +121,9 @@ public function gatherUrl(string $gatherUrl) { * * @param string $gatherMethod The http method to send the gather callback */ - public function gatherMethod(string $gatherMethod) { + public function gatherMethod(string $gatherMethod): Gather { $this->gatherMethod = $gatherMethod; + return $this; } /** @@ -126,8 +131,9 @@ public function gatherMethod(string $gatherMethod) { * * @param string $tag A custom string to be included in callbacks */ - public function tag(string $tag) { + public function tag(string $tag): Gather { $this->tag = $tag; + return $this; } /** @@ -135,8 +141,9 @@ public function tag(string $tag) { * * @param string $terminatingDigits Digits to terminate the gather */ - public function terminatingDigits(string $terminatingDigits) { + public function terminatingDigits(string $terminatingDigits): Gather { $this->terminatingDigits = $terminatingDigits; + return $this; } /** @@ -144,8 +151,9 @@ public function terminatingDigits(string $terminatingDigits) { * * @param int $maxDigits The maximum number of digits to collect in the gather */ - public function maxDigits(int $maxDigits) { + public function maxDigits(int $maxDigits): Gather { $this->maxDigits = $maxDigits; + return $this; } /** @@ -153,8 +161,9 @@ public function maxDigits(int $maxDigits) { * * @param int $interDigitTimeout The time in secods between digit presses before timing out */ - public function interDigitTimeout(int $interDigitTimeout) { + public function interDigitTimeout(int $interDigitTimeout): Gather { $this->interDigitTimeout = $interDigitTimeout; + return $this; } /** @@ -162,8 +171,9 @@ public function interDigitTimeout(int $interDigitTimeout) { * * @param int $firstDigitTimeout The time in seconds before the first digit is pressed before timing out */ - public function firstDigitTimeout(int $firstDigitTimeout) { + public function firstDigitTimeout(int $firstDigitTimeout): Gather { $this->firstDigitTimeout = $firstDigitTimeout; + return $this; } /** @@ -171,9 +181,9 @@ public function firstDigitTimeout(int $firstDigitTimeout) { * * @param PlayAudio $playAudio The PlayAudio tag to include in the Gather */ - public function playAudio(PlayAudio $playAudio) { + public function playAudio(PlayAudio $playAudio): Gather { $this->playAudio = $playAudio; - $this->addNestableVerb($playAudio); + return $this->addNestableVerb($playAudio); } /** @@ -181,8 +191,9 @@ public function playAudio(PlayAudio $playAudio) { * * @param int $repeatCount The number of times to repeat the played audio */ - public function repeatCount(int $repeatCount) { + public function repeatCount(int $repeatCount): Gather { $this->repeatCount = $repeatCount; + return $this; } /** @@ -190,9 +201,9 @@ public function repeatCount(int $repeatCount) { * * @param SpeakSentence $speakSentence The SpeakSentence tag to include in the Gather */ - public function speakSentence(SpeakSentence $speakSentence) { + public function speakSentence(SpeakSentence $speakSentence): Gather { $this->speakSentence = $speakSentence; - $this->addNestableVerb($speakSentence); + return $this->addNestableVerb($speakSentence); } /** @@ -200,8 +211,9 @@ public function speakSentence(SpeakSentence $speakSentence) { * * @param string $gatherFallbackUrl Fallback url for gather events */ - public function gatherFallbackUrl(string $gatherFallbackUrl) { + public function gatherFallbackUrl(string $gatherFallbackUrl): Gather { $this->gatherFallbackUrl = $gatherFallbackUrl; + return $this; } /** @@ -209,8 +221,9 @@ public function gatherFallbackUrl(string $gatherFallbackUrl) { * * @param string $gatherFallbackMethod HTTP method for fallback events */ - public function gatherFallbackMethod(string $gatherFallbackMethod) { + public function gatherFallbackMethod(string $gatherFallbackMethod): Gather { $this->gatherFallbackMethod = $gatherFallbackMethod; + return $this; } /** @@ -218,8 +231,9 @@ public function gatherFallbackMethod(string $gatherFallbackMethod) { * * @param string $fallbackUsername HTTP basic auth username for fallback events */ - public function fallbackUsername(string $fallbackUsername) { + public function fallbackUsername(string $fallbackUsername): Gather { $this->fallbackUsername = $fallbackUsername; + return $this; } /** @@ -227,8 +241,9 @@ public function fallbackUsername(string $fallbackUsername) { * * @param string $fallbackPassword HTTP basic auth password for fallback events */ - public function fallbackPassword(string $fallbackPassword) { + public function fallbackPassword(string $fallbackPassword): Gather { $this->fallbackPassword = $fallbackPassword; + return $this; } /** @@ -236,14 +251,15 @@ public function fallbackPassword(string $fallbackPassword) { * * @param SpeakSentence|PlayAudio $verb The nestable verb to add */ - private function addNestableVerb($verb) { + private function addNestableVerb($verb): Gather { if(!isset($this->nestableVerbs)) { $this->nestableVerbs = []; } array_push($this->nestableVerbs, $verb); + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Gather"); if(isset($this->username)) { diff --git a/src/Voice/Bxml/Hangup.php b/src/Voice/Bxml/Hangup.php index 1b9edcd..a8ca057 100644 --- a/src/Voice/Bxml/Hangup.php +++ b/src/Voice/Bxml/Hangup.php @@ -10,12 +10,13 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; class Hangup extends Verb { - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Hangup"); return $element; } diff --git a/src/Voice/Bxml/Pause.php b/src/Voice/Bxml/Pause.php index a9a5442..94b1266 100644 --- a/src/Voice/Bxml/Pause.php +++ b/src/Voice/Bxml/Pause.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -24,11 +25,12 @@ class Pause extends Verb { * * @param float $duration The duration in seconds for the pause */ - public function duration(float $duration) { + public function duration(float $duration): Pause { $this->duration = $duration; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Pause"); if(isset($this->duration)) { diff --git a/src/Voice/Bxml/PauseRecording.php b/src/Voice/Bxml/PauseRecording.php index 0023b11..eb2839e 100644 --- a/src/Voice/Bxml/PauseRecording.php +++ b/src/Voice/Bxml/PauseRecording.php @@ -10,12 +10,13 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; class PauseRecording extends Verb { - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("PauseRecording"); return $element; } diff --git a/src/Voice/Bxml/PhoneNumber.php b/src/Voice/Bxml/PhoneNumber.php index 869f0a2..e5adcc1 100644 --- a/src/Voice/Bxml/PhoneNumber.php +++ b/src/Voice/Bxml/PhoneNumber.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -77,8 +78,9 @@ public function __construct(string $phoneNumber) { * * @param string $username The username for http authentication on the audio url */ - public function username(string $username) { + public function username(string $username): PhoneNumber { $this->username = $username; + return $this; } /** @@ -86,8 +88,9 @@ public function username(string $username) { * * @param string $password The password for http authentication on the audio url */ - public function password(string $password) { + public function password(string $password): PhoneNumber { $this->password = $password; + return $this; } /** @@ -95,8 +98,9 @@ public function password(string $password) { * * @param string $transferAnswerUrl The url to receive the transfer answered callback */ - public function transferAnswerUrl(string $transferAnswerUrl) { + public function transferAnswerUrl(string $transferAnswerUrl): PhoneNumber { $this->transferAnswerUrl = $transferAnswerUrl; + return $this; } /** @@ -104,8 +108,9 @@ public function transferAnswerUrl(string $transferAnswerUrl) { * * @param string $transferAnswerMethod The http method to send the transfer answered callback */ - public function transferAnswerMethod(string $transferAnswerMethod) { + public function transferAnswerMethod(string $transferAnswerMethod): PhoneNumber { $this->transferAnswerMethod = $transferAnswerMethod; + return $this; } /** @@ -113,8 +118,9 @@ public function transferAnswerMethod(string $transferAnswerMethod) { * * @param string $transferDisconnectUrl The url to receive the transfer disconnect callback */ - public function transferDisconnectUrl(string $transferDisconnectUrl) { + public function transferDisconnectUrl(string $transferDisconnectUrl): PhoneNumber { $this->transferDisconnectUrl = $transferDisconnectUrl; + return $this; } /** @@ -122,8 +128,9 @@ public function transferDisconnectUrl(string $transferDisconnectUrl) { * * @param string $transferDisconnectMethod The http method to send the transfer disconnect callback */ - public function transferDisconnectMethod(string $transferDisconnectMethod) { + public function transferDisconnectMethod(string $transferDisconnectMethod): PhoneNumber { $this->transferDisconnectMethod = $transferDisconnectMethod; + return $this; } /** @@ -131,8 +138,9 @@ public function transferDisconnectMethod(string $transferDisconnectMethod) { * * @param string $tag A custom string to be included in callbacks */ - public function tag(string $tag) { + public function tag(string $tag): PhoneNumber { $this->tag = $tag; + return $this; } /** @@ -140,8 +148,9 @@ public function tag(string $tag) { * * @param string $transferAnswerFallbackUrl Fallback URL for transfer answer events */ - public function transferAnswerFallbackUrl(string $transferAnswerFallbackUrl) { + public function transferAnswerFallbackUrl(string $transferAnswerFallbackUrl): PhoneNumber { $this->transferAnswerFallbackUrl = $transferAnswerFallbackUrl; + return $this; } /** @@ -149,8 +158,9 @@ public function transferAnswerFallbackUrl(string $transferAnswerFallbackUrl) { * * @param string $transferAnswerFallbackMethod HTTP method for fallback events */ - public function transferAnswerFallbackMethod(string $transferAnswerFallbackMethod) { + public function transferAnswerFallbackMethod(string $transferAnswerFallbackMethod): PhoneNumber { $this->transferAnswerFallbackMethod = $transferAnswerFallbackMethod; + return $this; } /** @@ -158,8 +168,9 @@ public function transferAnswerFallbackMethod(string $transferAnswerFallbackMetho * * @param string $fallbackUsername HTTP basic auth username for fallback events */ - public function fallbackUsername(string $fallbackUsername) { + public function fallbackUsername(string $fallbackUsername): PhoneNumber { $this->fallbackUsername = $fallbackUsername; + return $this; } /** @@ -167,11 +178,12 @@ public function fallbackUsername(string $fallbackUsername) { * * @param string $fallbackPassword HTTP basic auth password for fallback events */ - public function fallbackPassword(string $fallbackPassword) { + public function fallbackPassword(string $fallbackPassword): PhoneNumber { $this->fallbackPassword = $fallbackPassword; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("PhoneNumber"); $element->appendChild($doc->createTextNode($this->phoneNumber)); diff --git a/src/Voice/Bxml/PlayAudio.php b/src/Voice/Bxml/PlayAudio.php index 5409f4b..4c4defd 100644 --- a/src/Voice/Bxml/PlayAudio.php +++ b/src/Voice/Bxml/PlayAudio.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -41,8 +42,9 @@ public function __construct(string $url) { * * @param string $username The username for http authentication on the audio url */ - public function username(string $username) { + public function username(string $username): PlayAudio { $this->username = $username; + return $this; } /** @@ -50,11 +52,12 @@ public function username(string $username) { * * @param string $password The password for http authentication on the audio url */ - public function password(string $password) { + public function password(string $password): PlayAudio { $this->password = $password; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("PlayAudio"); $element->appendChild($doc->createTextNode($this->url)); diff --git a/src/Voice/Bxml/Record.php b/src/Voice/Bxml/Record.php index ec78d78..bff91c6 100644 --- a/src/Voice/Bxml/Record.php +++ b/src/Voice/Bxml/Record.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -96,8 +97,9 @@ class Record extends Verb { * * @param string $tag A custom string to be included in callbacks */ - public function tag(string $tag) { + public function tag(string $tag): Record { $this->tag = $tag; + return $this; } /** @@ -105,8 +107,9 @@ public function tag(string $tag) { * * @param string $recordCompleteUrl URL to send the record complete callback to */ - public function recordCompleteUrl(string $recordCompleteUrl) { + public function recordCompleteUrl(string $recordCompleteUrl): Record { $this->recordCompleteUrl = $recordCompleteUrl; + return $this; } /** @@ -115,8 +118,9 @@ public function recordCompleteUrl(string $recordCompleteUrl) { * @param string $recordCompleteMethod HTTP method to send record complete * as ("GET" or "POST") */ - public function recordCompleteMethod(string $recordCompleteMethod) { + public function recordCompleteMethod(string $recordCompleteMethod): Record { $this->recordCompleteMethod = $recordCompleteMethod; + return $this; } /** @@ -124,8 +128,9 @@ public function recordCompleteMethod(string $recordCompleteMethod) { * * @param string $recordingAvailableUrl URL to send the record available callback to */ - public function recordingAvailableUrl(string $recordingAvailableUrl) { + public function recordingAvailableUrl(string $recordingAvailableUrl): Record { $this->recordingAvailableUrl = $recordingAvailableUrl; + return $this; } /** @@ -134,8 +139,9 @@ public function recordingAvailableUrl(string $recordingAvailableUrl) { * @param string $recordingAvailableMethod HTTP method to send record available * as ("GET" or "POST") */ - public function recordingAvailableMethod(string $recordingAvailableMethod) { + public function recordingAvailableMethod(string $recordingAvailableMethod): Record { $this->recordingAvailableMethod = $recordingAvailableMethod; + return $this; } /** @@ -143,8 +149,9 @@ public function recordingAvailableMethod(string $recordingAvailableMethod) { * * @param string $username Username for basic auth for callbacks */ - public function username(string $username) { + public function username(string $username): Record { $this->username = $username; + return $this; } /** @@ -152,8 +159,9 @@ public function username(string $username) { * * @param string $password Password for basic auth for callbacks */ - public function password(string $password) { + public function password(string $password): Record { $this->password = $password; + return $this; } /** @@ -161,8 +169,9 @@ public function password(string $password) { * * @param string $terminatingDigits Digits to terminate the recording */ - public function terminatingDigits(string $terminatingDigits) { + public function terminatingDigits(string $terminatingDigits): Record { $this->terminatingDigits = $terminatingDigits; + return $this; } /** @@ -170,8 +179,9 @@ public function terminatingDigits(string $terminatingDigits) { * * @param int $maxDuration Maximum length of the recording in secods */ - public function maxDuration(int $maxDuration) { + public function maxDuration(int $maxDuration): Record { $this->maxDuration = $maxDuration; + return $this; } /** @@ -179,8 +189,9 @@ public function maxDuration(int $maxDuration) { * * @param string $fileFormat Audio format of the recording ("mp3" or "wav") */ - public function fileFormat(string $fileFormat) { + public function fileFormat(string $fileFormat): Record { $this->fileFormat = $fileFormat; + return $this; } /** @@ -188,8 +199,9 @@ public function fileFormat(string $fileFormat) { * * @param boolean $detectLanguage Indicates that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish. */ - public function detectLanguage($detectLanguage) { + public function detectLanguage($detectLanguage): Record { $this->detectLanguage = $detectLanguage; + return $this; } /** @@ -197,8 +209,9 @@ public function detectLanguage($detectLanguage) { * * @param boolean $transcribe True to submit the recording for transcription, false otherwise */ - public function transcribe(bool $transcribe) { + public function transcribe(bool $transcribe): Record { $this->transcribe = $transcribe; + return $this; } /** @@ -206,8 +219,9 @@ public function transcribe(bool $transcribe) { * * @param string $transcriptionAvailableUrl URL to send transcription available events to */ - public function transcriptionAvailableUrl(string $transcriptionAvailableUrl) { + public function transcriptionAvailableUrl(string $transcriptionAvailableUrl): Record { $this->transcriptionAvailableUrl = $transcriptionAvailableUrl; + return $this; } /** @@ -215,8 +229,9 @@ public function transcriptionAvailableUrl(string $transcriptionAvailableUrl) { * * @param string $transcriptionAvailableMethod HTTP method (GET or POST) to send the transcription available event as */ - public function transcriptionAvailableMethod(string $transcriptionAvailableMethod) { + public function transcriptionAvailableMethod(string $transcriptionAvailableMethod): Record { $this->transcriptionAvailableMethod = $transcriptionAvailableMethod; + return $this; } /** @@ -224,8 +239,9 @@ public function transcriptionAvailableMethod(string $transcriptionAvailableMetho * * @param int $silenceTimeout Number of seconds of silence that ends the recording */ - public function silenceTimeout(int $silenceTimeout) { + public function silenceTimeout(int $silenceTimeout): Record { $this->silenceTimeout = $silenceTimeout; + return $this; } /** @@ -233,8 +249,9 @@ public function silenceTimeout(int $silenceTimeout) { * * @param string $recordCompleteFallbackUrl Fallback URL for record complete events */ - public function recordCompleteFallbackUrl(string $recordCompleteFallbackUrl) { + public function recordCompleteFallbackUrl(string $recordCompleteFallbackUrl): Record { $this->recordCompleteFallbackUrl = $recordCompleteFallbackUrl; + return $this; } /** @@ -242,8 +259,9 @@ public function recordCompleteFallbackUrl(string $recordCompleteFallbackUrl) { * * @param string $recordCompleteFallbackMethod HTTP method for fallback events */ - public function recordCompleteFallbackMethod(string $recordCompleteFallbackMethod) { + public function recordCompleteFallbackMethod(string $recordCompleteFallbackMethod): Record { $this->recordCompleteFallbackMethod = $recordCompleteFallbackMethod; + return $this; } /** @@ -251,8 +269,9 @@ public function recordCompleteFallbackMethod(string $recordCompleteFallbackMetho * * @param string $fallbackUsername HTTP basic auth username for fallback events */ - public function fallbackUsername(string $fallbackUsername) { + public function fallbackUsername(string $fallbackUsername): Record { $this->fallbackUsername = $fallbackUsername; + return $this; } /** @@ -260,11 +279,12 @@ public function fallbackUsername(string $fallbackUsername) { * * @param string $fallbackPassword HTTP basic auth password for fallback events */ - public function fallbackPassword(string $fallbackPassword) { + public function fallbackPassword(string $fallbackPassword): Record { $this->fallbackPassword = $fallbackPassword; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Record"); if(isset($this->tag)) { diff --git a/src/Voice/Bxml/Redirect.php b/src/Voice/Bxml/Redirect.php index 8968831..c2215ea 100644 --- a/src/Voice/Bxml/Redirect.php +++ b/src/Voice/Bxml/Redirect.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -56,8 +57,9 @@ class Redirect extends Verb { * * @param string $username The username for http authentication on the redirect callback url */ - public function username(string $username) { + public function username(string $username): Redirect { $this->username = $username; + return $this; } /** @@ -65,8 +67,9 @@ public function username(string $username) { * * @param string $password The password for http authentication on the redirect callback url */ - public function password(string $password) { + public function password(string $password): Redirect { $this->password = $password; + return $this; } /** @@ -74,8 +77,9 @@ public function password(string $password) { * * @param string $redirectUrl The url to receive the redirect callback */ - public function redirectUrl(string $redirectUrl) { + public function redirectUrl(string $redirectUrl): Redirect { $this->redirectUrl = $redirectUrl; + return $this; } /** @@ -83,8 +87,9 @@ public function redirectUrl(string $redirectUrl) { * * @param string $redirectMethod The http method to send the redirect callback */ - public function redirectMethod(string $redirectMethod) { + public function redirectMethod(string $redirectMethod): Redirect { $this->redirectMethod = $redirectMethod; + return $this; } /** @@ -92,8 +97,9 @@ public function redirectMethod(string $redirectMethod) { * * @param string $tag A custom string to be included in callbacks */ - public function tag(string $tag) { + public function tag(string $tag): Redirect { $this->tag = $tag; + return $this; } /** @@ -101,8 +107,9 @@ public function tag(string $tag) { * * @param string $redirectFallbackUrl Fallback url for redirect events */ - public function redirectFallbackUrl(string $redirectFallbackUrl) { + public function redirectFallbackUrl(string $redirectFallbackUrl): Redirect { $this->redirectFallbackUrl = $redirectFallbackUrl; + return $this; } /** @@ -110,8 +117,9 @@ public function redirectFallbackUrl(string $redirectFallbackUrl) { * * @param string $redirectFallbackMethod HTTP method for fallback events */ - public function redirectFallbackMethod(string $redirectFallbackMethod) { + public function redirectFallbackMethod(string $redirectFallbackMethod): Redirect { $this->redirectFallbackMethod = $redirectFallbackMethod; + return $this; } /** @@ -119,8 +127,9 @@ public function redirectFallbackMethod(string $redirectFallbackMethod) { * * @param string $fallbackUsername HTTP basic auth username for fallback events */ - public function fallbackUsername(string $fallbackUsername) { + public function fallbackUsername(string $fallbackUsername): Redirect { $this->fallbackUsername = $fallbackUsername; + return $this; } /** @@ -128,11 +137,12 @@ public function fallbackUsername(string $fallbackUsername) { * * @param string $fallbackPassword HTTP basic auth password for fallback events */ - public function fallbackPassword(string $fallbackPassword) { + public function fallbackPassword(string $fallbackPassword): Redirect { $this->fallbackPassword = $fallbackPassword; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Redirect"); if(isset($this->username)) { diff --git a/src/Voice/Bxml/Response.php b/src/Voice/Bxml/Response.php index cc6a1a8..ffc80f1 100644 --- a/src/Voice/Bxml/Response.php +++ b/src/Voice/Bxml/Response.php @@ -29,8 +29,9 @@ public function __construct() { * * @param Verb $verb The verb to add to the list */ - public function addVerb(Verb $verb) { + public function addVerb(Verb $verb): Response { array_push($this->verbs, $verb); + return $this; } /** @@ -38,7 +39,7 @@ public function addVerb(Verb $verb) { * * @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'); $responseElement = $doc->createElement("Response"); @@ -51,7 +52,7 @@ public function toBxml() { return str_replace("\n", '', preg_replace($ssmlRegex, "<$1>", $doc->saveXML())); } - public function __toString() + public function __toString(): string { return $this->toBxml(); } diff --git a/src/Voice/Bxml/ResumeRecording.php b/src/Voice/Bxml/ResumeRecording.php index f3537fd..d414cf8 100644 --- a/src/Voice/Bxml/ResumeRecording.php +++ b/src/Voice/Bxml/ResumeRecording.php @@ -10,12 +10,13 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; class ResumeRecording extends Verb { - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("ResumeRecording"); return $element; } diff --git a/src/Voice/Bxml/Ring.php b/src/Voice/Bxml/Ring.php index fd90307..a5cacfa 100644 --- a/src/Voice/Bxml/Ring.php +++ b/src/Voice/Bxml/Ring.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -28,8 +29,9 @@ class Ring extends Verb { * * @param float $duration The duration in seconds for the ring */ - public function duration(float $duration) { + public function duration(float $duration): Ring { $this->duration = $duration; + return $this; } /** @@ -37,11 +39,12 @@ public function duration(float $duration) { * * @param boolean $answerCall Determines whether or not to answer the call when Ring is executed on an unanswered incoming call */ - public function answerCall(bool $answerCall) { + public function answerCall(bool $answerCall): Ring { $this->answerCall = $answerCall; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Ring"); if(isset($this->duration)) { diff --git a/src/Voice/Bxml/SendDtmf.php b/src/Voice/Bxml/SendDtmf.php index 4682a72..f07fddb 100644 --- a/src/Voice/Bxml/SendDtmf.php +++ b/src/Voice/Bxml/SendDtmf.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -41,8 +42,9 @@ public function __construct(string $digits) { * * @param double $toneDuration The length in milliseconds of each DTMF tone */ - public function toneDuration(float $toneDuration) { + public function toneDuration(float $toneDuration): SendDtmf { $this->toneDuration = $toneDuration; + return $this; } /** @@ -50,11 +52,12 @@ public function toneDuration(float $toneDuration) { * * @param double $toneInterval The duration of silence in milliseconds following each DTMF tone */ - public function toneInterval(float $toneInterval) { + public function toneInterval(float $toneInterval): SendDtmf { $this->toneInterval = $toneInterval; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("SendDtmf"); $element->appendChild($doc->createTextNode($this->digits)); diff --git a/src/Voice/Bxml/SipUri.php b/src/Voice/Bxml/SipUri.php index 6e019de..743f512 100644 --- a/src/Voice/Bxml/SipUri.php +++ b/src/Voice/Bxml/SipUri.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -81,8 +82,9 @@ public function __construct(string $sip) { * * @param string $username The username for http authentication on the audio url */ - public function username(string $username) { + public function username(string $username): SipUri { $this->username = $username; + return $this; } /** @@ -90,8 +92,9 @@ public function username(string $username) { * * @param string $password The password for http authentication on the audio url */ - public function password(string $password) { + public function password(string $password): SipUri { $this->password = $password; + return $this; } /** @@ -99,8 +102,9 @@ public function password(string $password) { * * @param string $transferAnswerUrl The url to receive the transfer answered callback */ - public function transferAnswerUrl(string $transferAnswerUrl) { + public function transferAnswerUrl(string $transferAnswerUrl): SipUri { $this->transferAnswerUrl = $transferAnswerUrl; + return $this; } /** @@ -108,8 +112,9 @@ public function transferAnswerUrl(string $transferAnswerUrl) { * * @param string $transferAnswerMethod The http method to send the transfer answered callback */ - public function transferAnswerMethod(string $transferAnswerMethod) { + public function transferAnswerMethod(string $transferAnswerMethod): SipUri { $this->transferAnswerMethod = $transferAnswerMethod; + return $this; } /** @@ -117,8 +122,9 @@ public function transferAnswerMethod(string $transferAnswerMethod) { * * @param string $transferDisconnectUrl The url to receive the transfer disconnect callback */ - public function transferDisconnectUrl(string $transferDisconnectUrl) { + public function transferDisconnectUrl(string $transferDisconnectUrl): SipUri { $this->transferDisconnectUrl = $transferDisconnectUrl; + return $this; } /** @@ -126,8 +132,9 @@ public function transferDisconnectUrl(string $transferDisconnectUrl) { * * @param string $transferDisconnectMethod The http method to send the transfer disconnect callback */ - public function transferDisconnectMethod(string $transferDisconnectMethod) { + public function transferDisconnectMethod(string $transferDisconnectMethod): SipUri { $this->transferDisconnectMethod = $transferDisconnectMethod; + return $this; } /** @@ -135,8 +142,9 @@ public function transferDisconnectMethod(string $transferDisconnectMethod) { * * @param string $tag A custom string to be included in callbacks */ - public function tag(string $tag) { + public function tag(string $tag): SipUri { $this->tag = $tag; + return $this; } /** @@ -144,8 +152,9 @@ public function tag(string $tag) { * * @param string $uui The value of the `User-To-User` header to send within the initial `INVITE` */ - public function uui(string $uui) { + public function uui(string $uui): SipUri { $this->uui = $uui; + return $this; } /** @@ -153,8 +162,9 @@ public function uui(string $uui) { * * @param string $transferAnswerFallbackUrl Fallback URL for transfer answer events */ - public function transferAnswerFallbackUrl(string $transferAnswerFallbackUrl) { + public function transferAnswerFallbackUrl(string $transferAnswerFallbackUrl): SipUri { $this->transferAnswerFallbackUrl = $transferAnswerFallbackUrl; + return $this; } /** @@ -162,8 +172,9 @@ public function transferAnswerFallbackUrl(string $transferAnswerFallbackUrl) { * * @param string $transferAnswerFallbackMethod HTTP method for fallback events */ - public function transferAnswerFallbackMethod(string $transferAnswerFallbackMethod) { + public function transferAnswerFallbackMethod(string $transferAnswerFallbackMethod): SipUri { $this->transferAnswerFallbackMethod = $transferAnswerFallbackMethod; + return $this; } /** @@ -171,8 +182,9 @@ public function transferAnswerFallbackMethod(string $transferAnswerFallbackMetho * * @param string $fallbackUsername HTTP basic auth username for fallback events */ - public function fallbackUsername(string $fallbackUsername) { + public function fallbackUsername(string $fallbackUsername): SipUri { $this->fallbackUsername = $fallbackUsername; + return $this; } /** @@ -180,11 +192,12 @@ public function fallbackUsername(string $fallbackUsername) { * * @param string $fallbackPassword HTTP basic auth password for fallback events */ - public function fallbackPassword(string $fallbackPassword) { + public function fallbackPassword(string $fallbackPassword): SipUri { $this->fallbackPassword = $fallbackPassword; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("SipUri"); $element->appendChild($doc->createTextNode($this->sip)); diff --git a/src/Voice/Bxml/SpeakSentence.php b/src/Voice/Bxml/SpeakSentence.php index 7e25e62..e6f3d68 100644 --- a/src/Voice/Bxml/SpeakSentence.php +++ b/src/Voice/Bxml/SpeakSentence.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -45,8 +46,9 @@ public function __construct(string $sentence) { * * @param string $voice The voice to speak in the call */ - public function voice(string $voice) { + public function voice(string $voice): SpeakSentence { $this->voice = $voice; + return $this; } /** @@ -54,8 +56,9 @@ public function voice(string $voice) { * * @param string $locale The locale of the voice in the call */ - public function locale(string $locale) { + public function locale(string $locale): SpeakSentence { $this->locale = $locale; + return $this; } /** @@ -63,11 +66,12 @@ public function locale(string $locale) { * * @param string $gender The gender of the voice in the call */ - public function gender(string $gender) { + public function gender(string $gender): SpeakSentence { $this->gender = $gender; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("SpeakSentence"); $element->appendChild($doc->createTextNode($this->sentence)); diff --git a/src/Voice/Bxml/StartGather.php b/src/Voice/Bxml/StartGather.php index cf9469b..3c684d3 100644 --- a/src/Voice/Bxml/StartGather.php +++ b/src/Voice/Bxml/StartGather.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; require_once "SpeakSentence.php"; @@ -42,8 +43,9 @@ class StartGather extends Verb { * * @param string $username The username for http authentication for the gather callback */ - public function username(string $username) { + public function username(string $username): StartGather { $this->username = $username; + return $this; } /** @@ -51,8 +53,9 @@ public function username(string $username) { * * @param string $password The password for http authentication for the gather callback */ - public function password(string $password) { + public function password(string $password): StartGather { $this->password = $password; + return $this; } /** @@ -60,8 +63,9 @@ public function password(string $password) { * * @param string $dtmfUrl The url to receive the dtmf callback */ - public function dtmfUrl(string $dtmfUrl) { + public function dtmfUrl(string $dtmfUrl): StartGather { $this->dtmfUrl = $dtmfUrl; + return $this; } /** @@ -69,8 +73,9 @@ public function dtmfUrl(string $dtmfUrl) { * * @param string $dtmfMethod The http method to send the dtmf callback */ - public function dtmfMethod(string $dtmfMethod) { + public function dtmfMethod(string $dtmfMethod): StartGather { $this->dtmfMethod = $dtmfMethod; + return $this; } /** @@ -78,11 +83,12 @@ public function dtmfMethod(string $dtmfMethod) { * * @param string $tag A custom string to be included in callbacks */ - public function tag(string $tag) { + public function tag(string $tag): StartGather { $this->tag = $tag; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StartGather"); if(isset($this->username)) { diff --git a/src/Voice/Bxml/StartRecording.php b/src/Voice/Bxml/StartRecording.php index c6460c1..627689d 100644 --- a/src/Voice/Bxml/StartRecording.php +++ b/src/Voice/Bxml/StartRecording.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -64,8 +65,9 @@ class StartRecording extends Verb { * * @param string $tag A custom string to be included in callbacks */ - public function tag(string $tag) { + public function tag(string $tag): StartRecording { $this->tag = $tag; + return $this; } /** @@ -73,8 +75,9 @@ public function tag(string $tag) { * * @param string $recordingAvailableUrl URL to send the record available callback to */ - public function recordingAvailableUrl(string $recordingAvailableUrl) { + public function recordingAvailableUrl(string $recordingAvailableUrl): StartRecording { $this->recordingAvailableUrl = $recordingAvailableUrl; + return $this; } /** @@ -83,8 +86,9 @@ public function recordingAvailableUrl(string $recordingAvailableUrl) { * @param string $recordingAvailableMethod HTTP method to send record available * as ("GET" or "POST") */ - public function recordingAvailableMethod(string $recordingAvailableMethod) { + public function recordingAvailableMethod(string $recordingAvailableMethod): StartRecording { $this->recordingAvailableMethod = $recordingAvailableMethod; + return $this; } /** @@ -92,8 +96,9 @@ public function recordingAvailableMethod(string $recordingAvailableMethod) { * * @param string $username Username for basic auth for callbacks */ - public function username(string $username) { + public function username(string $username): StartRecording { $this->username = $username; + return $this; } /** @@ -101,8 +106,9 @@ public function username(string $username) { * * @param string $password Password for basic auth for callbacks */ - public function password(string $password) { + public function password(string $password): StartRecording { $this->password = $password; + return $this; } /** @@ -110,8 +116,9 @@ public function password(string $password) { * * @param string $fileFormat Audio format of the recording ("mp3" or "wav") */ - public function fileFormat(string $fileFormat) { + public function fileFormat(string $fileFormat): StartRecording { $this->fileFormat = $fileFormat; + return $this; } /** @@ -119,8 +126,9 @@ public function fileFormat(string $fileFormat) { * * @param boolean $detectLanguage Indicates that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish. */ - public function detectLanguage($detectLanguage) { + public function detectLanguage($detectLanguage): StartRecording { $this->detectLanguage = $detectLanguage; + return $this; } @@ -129,8 +137,9 @@ public function detectLanguage($detectLanguage) { * * @param bool $multiChannel True to record the audio as 2 channels, false otherwise */ - public function multiChannel(bool $multiChannel) { + public function multiChannel(bool $multiChannel): StartRecording { $this->multiChannel = $multiChannel; + return $this; } /** @@ -138,8 +147,9 @@ public function multiChannel(bool $multiChannel) { * * @param boolean $transcribe True to submit the recording for transcription, false otherwise */ - public function transcribe(bool $transcribe) { + public function transcribe(bool $transcribe): StartRecording { $this->transcribe = $transcribe; + return $this; } /** @@ -147,8 +157,9 @@ public function transcribe(bool $transcribe) { * * @param string $transcriptionAvailableUrl URL to send transcription available events to */ - public function transcriptionAvailableUrl(string $transcriptionAvailableUrl) { + public function transcriptionAvailableUrl(string $transcriptionAvailableUrl): StartRecording { $this->transcriptionAvailableUrl = $transcriptionAvailableUrl; + return $this; } /** @@ -156,11 +167,12 @@ public function transcriptionAvailableUrl(string $transcriptionAvailableUrl) { * * @param string $transcriptionAvailableMethod HTTP method (GET or POST) to send the transcription available event as */ - public function transcriptionAvailableMethod(string $transcriptionAvailableMethod) { + public function transcriptionAvailableMethod(string $transcriptionAvailableMethod): StartRecording { $this->transcriptionAvailableMethod = $transcriptionAvailableMethod; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StartRecording"); if(isset($this->tag)) { diff --git a/src/Voice/Bxml/StartStream.php b/src/Voice/Bxml/StartStream.php index 3134a11..0d7b1b4 100644 --- a/src/Voice/Bxml/StartStream.php +++ b/src/Voice/Bxml/StartStream.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -49,8 +50,9 @@ class StartStream extends Verb { * * @param string $destination A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL encoded as base64 encoded PCMU/G711 audio. See below for more details on the websocket packet format. */ - public function destination(string $destination) { + public function destination(string $destination): StartStream { $this->destination = $destination; + return $this; } /** @@ -58,8 +60,9 @@ public function destination(string $destination) { * * @param string $name A name to refer to this stream by. Used when sending [``][1]. If not provided, a random name will be generated and sent in the [`Media Stream Started`][2] webook */ - public function name(string $name) { + public function name(string $name): StartStream { $this->name = $name; + return $this; } /** @@ -68,8 +71,9 @@ public function name(string $name) { * @param string $tracks The part of the call to send a stream from. `inbound`, `outbound` or `both`. Default is `inbound`. * */ - public function tracks(string $tracks) { + public function tracks(string $tracks): StartStream { $this->tracks = $tracks; + return $this; } /** @@ -77,8 +81,9 @@ public function tracks(string $tracks) { * * @param string $username The username to send in the HTTP request to `streamEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`). */ - public function username(string $username) { + public function username(string $username): StartStream { $this->username = $username; + return $this; } /** @@ -86,8 +91,9 @@ public function username(string $username) { * * @param string $password The password to send in the HTTP request to `streamEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`). */ - public function password(string $password) { + public function password(string $password): StartStream { $this->password = $password; + return $this; } /** @@ -95,8 +101,9 @@ public function password(string $password) { * * @param string $streamEventUrl URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL. */ - public function streamEventUrl(string $streamEventUrl) { + public function streamEventUrl(string $streamEventUrl): StartStream { $this->streamEventUrl = $streamEventUrl; + return $this; } /** @@ -104,8 +111,9 @@ public function streamEventUrl(string $streamEventUrl) { * * @param bool $streamEventMethod The HTTP method to use for the request to `streamEventUrl`. GET or POST. Default value is POST. */ - public function streamEventMethod(string $streamEventMethod) { + public function streamEventMethod(string $streamEventMethod): StartStream { $this->streamEventMethod = $streamEventMethod; + return $this; } /** @@ -113,11 +121,12 @@ public function streamEventMethod(string $streamEventMethod) { * * @param list $streamParams The list of StreamParam tags */ - public function streamParams($streamParams) { + public function streamParams($streamParams): StartStream { $this->streamParams = $streamParams; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StartStream"); if(isset($this->destination)) { diff --git a/src/Voice/Bxml/StartTranscription.php b/src/Voice/Bxml/StartTranscription.php index 8af92ee..c9c81cc 100644 --- a/src/Voice/Bxml/StartTranscription.php +++ b/src/Voice/Bxml/StartTranscription.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -53,8 +54,9 @@ class StartTranscription extends Verb { * * @param string $destination A websocket URI to send the real-time transcription to. The audio from the specified tracks will be sent via websocket to this URL encoded as base64 encoded PCMU/G711 audio. See below for more details on the websocket packet format. */ - public function destination(string $destination) { + public function destination(string $destination): StartTranscription { $this->destination = $destination; + return $this; } /** @@ -62,8 +64,9 @@ public function destination(string $destination) { * * @param string $name A name to refer to this transcription by. Used when sending . If not provided, it will default to the generated transcription id as sent in the real-time Transcription Started webhook. */ - public function name(string $name) { + public function name(string $name): StartTranscription { $this->name = $name; + return $this; } /** @@ -72,8 +75,9 @@ public function name(string $name) { * @param string $tracks The part of the call to send a real-time transcription from. `inbound`, `outbound` or `both`. Default is `inbound`. * */ - public function tracks(string $tracks) { + public function tracks(string $tracks): StartTranscription { $this->tracks = $tracks; + return $this; } /** @@ -81,8 +85,9 @@ public function tracks(string $tracks) { * * @param string $username The username to send in the HTTP request to `transcriptionEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`). */ - public function username(string $username) { + public function username(string $username): StartTranscription { $this->username = $username; + return $this; } /** @@ -90,8 +95,9 @@ public function username(string $username) { * * @param string $password The password to send in the HTTP request to `transcriptionEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`). */ - public function password(string $password) { + public function password(string $password): StartTranscription { $this->password = $password; + return $this; } /** @@ -99,8 +105,9 @@ public function password(string $password) { * * @param string $transcriptionEventUrl URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL. */ - public function transcriptionEventUrl(string $transcriptionEventUrl) { + public function transcriptionEventUrl(string $transcriptionEventUrl): StartTranscription { $this->transcriptionEventUrl = $transcriptionEventUrl; + return $this; } /** @@ -108,8 +115,9 @@ public function transcriptionEventUrl(string $transcriptionEventUrl) { * * @param bool $transcriptionEventMethod The HTTP method to use for the request to `transcriptionEventUrl`. GET or POST. Default value is POST. */ - public function transcriptionEventMethod(string $transcriptionEventMethod) { + public function transcriptionEventMethod(string $transcriptionEventMethod): StartTranscription { $this->transcriptionEventMethod = $transcriptionEventMethod; + return $this; } /** @@ -118,8 +126,9 @@ public function transcriptionEventMethod(string $transcriptionEventMethod) { * @param bool Whether to send transcription update events to the specified destination only after they have become stable. Requires destination. Defaults to true. * */ - public function stability( bool $stability) { + public function stability( bool $stability): StartTranscription { $this->stability = $stability; + return $this; } /** @@ -127,11 +136,12 @@ public function stability( bool $stability) { * * @param list $customParams The list of CustomParam tags */ - public function customParams($customParams) { + public function customParams($customParams): StartTranscription { $this->customParams = $customParams; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StartTranscription"); if(isset($this->destination)) { diff --git a/src/Voice/Bxml/StopGather.php b/src/Voice/Bxml/StopGather.php index 3db8e82..bada923 100644 --- a/src/Voice/Bxml/StopGather.php +++ b/src/Voice/Bxml/StopGather.php @@ -10,12 +10,13 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; class StopGather extends Verb { - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StopGather"); return $element; } diff --git a/src/Voice/Bxml/StopRecording.php b/src/Voice/Bxml/StopRecording.php index f083112..511190f 100644 --- a/src/Voice/Bxml/StopRecording.php +++ b/src/Voice/Bxml/StopRecording.php @@ -10,12 +10,13 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; class StopRecording extends Verb { - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StopRecording"); return $element; } diff --git a/src/Voice/Bxml/StopStream.php b/src/Voice/Bxml/StopStream.php index 8f87240..3e195f5 100644 --- a/src/Voice/Bxml/StopStream.php +++ b/src/Voice/Bxml/StopStream.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -24,11 +25,12 @@ class StopStream extends Verb { * * @param string $name (required) The name of the stream to stop. This is either the user selected name when sending the [``][1] verb, or the system generated name returned in the [Media Stream Started][2] webhook if `` was sent with no `name` attribute. */ - public function name(string $name) { + public function name(string $name): StopStream { $this->name = $name; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StopStream"); if(isset($this->name)) { diff --git a/src/Voice/Bxml/StopTranscription.php b/src/Voice/Bxml/StopTranscription.php index 8f577fa..5392c8b 100644 --- a/src/Voice/Bxml/StopTranscription.php +++ b/src/Voice/Bxml/StopTranscription.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -24,11 +25,12 @@ class StopTranscription extends Verb { * * @param string $name (required) The name of the real-time transcription to stop. This is either the user selected name when sending the [``][1] verb, or the system generated name returned in the [Media Transcription Started][2] webhook if `` was sent with no `name` attribute. */ - public function name(string $name) { + public function name(string $name): StopTranscription { $this->name = $name; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StopTranscription"); if(isset($this->name)) { diff --git a/src/Voice/Bxml/StreamParam.php b/src/Voice/Bxml/StreamParam.php index 6775829..41d6814 100644 --- a/src/Voice/Bxml/StreamParam.php +++ b/src/Voice/Bxml/StreamParam.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -28,8 +29,9 @@ class StreamParam 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): StreamParam { $this->name = $name; + return $this; } /** @@ -37,11 +39,12 @@ public function name(string $name) { * * @param string $value (required) The value of this parameter, up to 2048 characters. */ - public function value(string $value) { + public function value(string $value): StreamParam { $this->value = $value; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("StreamParam"); if(isset($this->name)) { diff --git a/src/Voice/Bxml/Tag.php b/src/Voice/Bxml/Tag.php index 45cf5ae..88ddfa3 100644 --- a/src/Voice/Bxml/Tag.php +++ b/src/Voice/Bxml/Tag.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -28,7 +29,7 @@ public function __construct(string $tag) { $this->tag = $tag; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Tag"); $element->appendChild($doc->createTextNode($this->tag)); diff --git a/src/Voice/Bxml/Transfer.php b/src/Voice/Bxml/Transfer.php index caa70a2..45cdaad 100644 --- a/src/Voice/Bxml/Transfer.php +++ b/src/Voice/Bxml/Transfer.php @@ -10,6 +10,7 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; require_once "Verb.php"; @@ -78,8 +79,9 @@ class Transfer extends Verb { * * @param string $username The username for http authentication on the transfer answered callback url */ - public function username(string $username) { + public function username(string $username): Transfer { $this->username = $username; + return $this; } /** @@ -87,8 +89,9 @@ public function username(string $username) { * * @param string $password The password for http authentication on the transfer answered callback url */ - public function password(string $password) { + public function password(string $password): Transfer { $this->password = $password; + return $this; } /** @@ -96,8 +99,9 @@ public function password(string $password) { * * @param string $transferCompleteUrl The url to receive the transfer answered callback */ - public function transferCompleteUrl(string $transferCompleteUrl) { + public function transferCompleteUrl(string $transferCompleteUrl): Transfer { $this->transferCompleteUrl = $transferCompleteUrl; + return $this; } /** @@ -105,8 +109,9 @@ public function transferCompleteUrl(string $transferCompleteUrl) { * * @param string $transferCompleteMethod The http method to send the transfer answered callback */ - public function transferCompleteMethod(string $transferCompleteMethod) { + public function transferCompleteMethod(string $transferCompleteMethod): Transfer { $this->transferCompleteMethod = $transferCompleteMethod; + return $this; } /** @@ -114,15 +119,17 @@ public function transferCompleteMethod(string $transferCompleteMethod) { * * @param string $transferCallerId The caller id to use when the call is transferred */ - public function transferCallerId(string $transferCallerId) { + public function transferCallerId(string $transferCallerId): Transfer { $this->transferCallerId = $transferCallerId; + return $this; } /** * Sets the transferCallerDisplayName attribute for Transfer */ - public function transferCallerDisplayName(string $transferCallerDisplayName) { + public function transferCallerDisplayName(string $transferCallerDisplayName): Transfer { $this->transferCallerDisplayName = $transferCallerDisplayName; + return $this; } /** @@ -130,8 +137,9 @@ public function transferCallerDisplayName(string $transferCallerDisplayName) { * * @param int $callTimeout The number of seconds to wait before timing out the call */ - public function callTimeout(int $callTimeout) { + public function callTimeout(int $callTimeout): Transfer { $this->callTimeout = $callTimeout; + return $this; } /** @@ -139,8 +147,9 @@ public function callTimeout(int $callTimeout) { * * @param string $tag A custom string to be included in callbacks */ - public function tag(string $tag) { + public function tag(string $tag): Transfer { $this->tag = $tag; + return $this; } /** @@ -148,8 +157,9 @@ public function tag(string $tag) { * * @param string $diversionTreatment The diversion treatment for the phone call */ - public function diversionTreatment(string $diversionTreatment) { + public function diversionTreatment(string $diversionTreatment): Transfer { $this->diversionTreatment = $diversionTreatment; + return $this; } /** @@ -157,8 +167,9 @@ public function diversionTreatment(string $diversionTreatment) { * * @param string $diversionReason The diversion treatment for the phone call */ - public function diversionReason(string $diversionReason) { + public function diversionReason(string $diversionReason): Transfer { $this->diversionReason = $diversionReason; + return $this; } /** @@ -166,8 +177,9 @@ public function diversionReason(string $diversionReason) { * * @param list $phoneNumbers The list of PhoneNumber tags */ - public function phoneNumbers($phoneNumbers) { + public function phoneNumbers($phoneNumbers): Transfer { $this->phoneNumbers = $phoneNumbers; + return $this; } /** @@ -175,8 +187,9 @@ public function phoneNumbers($phoneNumbers) { * * @param list $sipUris The list of SipUri tags */ - public function sipUris($sipUris) { + public function sipUris($sipUris): Transfer { $this->sipUris = $sipUris; + return $this; } /** @@ -184,8 +197,9 @@ public function sipUris($sipUris) { * * @param string $transferCompleteFallbackUrl Fallback url for transfer complete events */ - public function transferCompleteFallbackUrl(string $transferCompleteFallbackUrl) { + public function transferCompleteFallbackUrl(string $transferCompleteFallbackUrl): Transfer { $this->transferCompleteFallbackUrl = $transferCompleteFallbackUrl; + return $this; } /** @@ -193,8 +207,9 @@ public function transferCompleteFallbackUrl(string $transferCompleteFallbackUrl) * * @param string $transferCompleteFallbackMethod HTTP method for fallback events */ - public function transferCompleteFallbackMethod(string $transferCompleteFallbackMethod) { + public function transferCompleteFallbackMethod(string $transferCompleteFallbackMethod): Transfer { $this->transferCompleteFallbackMethod = $transferCompleteFallbackMethod; + return $this; } /** @@ -202,8 +217,9 @@ public function transferCompleteFallbackMethod(string $transferCompleteFallbackM * * @param string $fallbackUsername HTTP basic auth username for fallback events */ - public function fallbackUsername(string $fallbackUsername) { + public function fallbackUsername(string $fallbackUsername): Transfer { $this->fallbackUsername = $fallbackUsername; + return $this; } /** @@ -211,11 +227,12 @@ public function fallbackUsername(string $fallbackUsername) { * * @param string $fallbackPassword HTTP basic auth password for fallback events */ - public function fallbackPassword(string $fallbackPassword) { + public function fallbackPassword(string $fallbackPassword): Transfer { $this->fallbackPassword = $fallbackPassword; + return $this; } - public function toBxml(DOMDocument $doc) { + public function toBxml(DOMDocument $doc): DOMElement { $element = $doc->createElement("Transfer"); if(isset($this->username)) { diff --git a/src/Voice/Bxml/Verb.php b/src/Voice/Bxml/Verb.php index 0d6a084..91ae841 100644 --- a/src/Voice/Bxml/Verb.php +++ b/src/Voice/Bxml/Verb.php @@ -10,15 +10,16 @@ namespace BandwidthLib\Voice\Bxml; use DOMDocument; +use DOMElement; abstract class Verb { /** * Converts the verb class into a DOMElement to build the complete BXML * -// * @param DOMDocument $doc The document that is building the BXML -// * @return DOMElement The element representing the verb + * @param DOMDocument $doc The document that is building the BXML + * @return DOMElement The element representing the verb */ - abstract protected function toBxml(DOMDocument $doc); + abstract protected function toBxml(DOMDocument $doc): DOMElement; } From 6c282806a622b29a518f1b6c1f0516813cceac4c Mon Sep 17 00:00:00 2001 From: Ethan Ransdell Date: Wed, 3 Jul 2024 16:42:38 -0400 Subject: [PATCH 4/4] Add make function for verbs --- README.md | 12 ++++++------ src/Voice/Bxml/Verb.php | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 44b258b..97c8f8b 100644 --- a/README.md +++ b/README.md @@ -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(); ``` diff --git a/src/Voice/Bxml/Verb.php b/src/Voice/Bxml/Verb.php index 91ae841..2d058b2 100644 --- a/src/Voice/Bxml/Verb.php +++ b/src/Voice/Bxml/Verb.php @@ -22,4 +22,7 @@ abstract class Verb { */ abstract protected function toBxml(DOMDocument $doc): DOMElement; + public static function make(): static { + return new static(...func_get_args()); + } }