From 65ed736213ed917c69537e724dfd6bdfce37ce02 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 15 Mar 2016 14:18:00 +0200 Subject: [PATCH] Cleaner way to get response values for events. --- .../phparia/Events/BridgeAttendedTransfer.php | 55 ++++++++----------- .../phparia/Events/BridgeBlindTransfer.php | 22 +++----- src/wormling/phparia/Events/BridgeCreated.php | 3 +- .../phparia/Events/BridgeDestroyed.php | 3 +- src/wormling/phparia/Events/BridgeMerged.php | 5 +- .../phparia/Events/ChannelCallerId.php | 7 +-- .../phparia/Events/ChannelConnectedLine.php | 3 +- .../phparia/Events/ChannelCreated.php | 2 +- .../phparia/Events/ChannelDestroyed.php | 6 +- .../phparia/Events/ChannelDialplan.php | 6 +- .../phparia/Events/ChannelDtmfReceived.php | 6 +- .../phparia/Events/ChannelEnteredBridge.php | 5 +- .../phparia/Events/ChannelHangupRequest.php | 7 +-- .../phparia/Events/ChannelLeftBridge.php | 5 +- .../phparia/Events/ChannelStateChange.php | 3 +- .../phparia/Events/ChannelTalkingFinished.php | 5 +- .../phparia/Events/ChannelTalkingStarted.php | 3 +- .../phparia/Events/ChannelUserevent.php | 17 ++---- src/wormling/phparia/Events/ChannelVarset.php | 8 +-- .../phparia/Events/DeviceStateChange.php | 3 +- src/wormling/phparia/Events/Dial.php | 15 ++--- .../phparia/Events/EndpointStateChange.php | 3 +- src/wormling/phparia/Events/Event.php | 6 +- src/wormling/phparia/Events/Message.php | 3 +- .../phparia/Events/PlaybackFinished.php | 3 +- .../phparia/Events/PlaybackStarted.php | 3 +- .../phparia/Events/RecordingFailed.php | 3 +- .../phparia/Events/RecordingFinished.php | 3 +- .../phparia/Events/RecordingStarted.php | 3 +- src/wormling/phparia/Events/StasisEnd.php | 3 +- src/wormling/phparia/Events/StasisStart.php | 8 +-- .../phparia/Events/TextMessageReceived.php | 6 +- 32 files changed, 92 insertions(+), 141 deletions(-) diff --git a/src/wormling/phparia/Events/BridgeAttendedTransfer.php b/src/wormling/phparia/Events/BridgeAttendedTransfer.php index 46839a9..ba61fc5 100644 --- a/src/wormling/phparia/Events/BridgeAttendedTransfer.php +++ b/src/wormling/phparia/Events/BridgeAttendedTransfer.php @@ -27,7 +27,7 @@ * * @author Brian Smith */ -class BridgeAttendedTransfer extends Event +class BridgeAttendedTransfer extends BridgeTransfer { /** * @var string (optional) - Application that has been transferred into @@ -245,35 +245,28 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->destinationApplication = property_exists($this->response, - 'destination_application') ? $this->response->destination_application : null; - $this->destinationBridge = property_exists($this->response, - 'destination_bridge') ? $this->response->destination_bridge : null; - $this->destinationLinkFirstLeg = property_exists($this->response, - 'destination_link_first_leg') ? new Channel($client, $this->response->destination_link_first_leg) : null; - $this->destinationLinkSecondLeg = property_exists($this->response, - 'destination_link_second_leg') ? new Channel($client, $this->response->destination_link_second_leg) : null; - $this->destinationThreewayBridge = property_exists($this->response, - 'destination_threeway_bridge') ? new Bridge($client, $this->response->destination_threeway_bridge) : null; - $this->destinationThreewayChannel = property_exists($this->response, - 'destination_threeway_channel') ? new Channel($client, - $this->response->destination_threeway_channel) : null; - $this->destinationType = property_exists($this->response, - 'destination_type') ? $this->response->destination_type : null; - $this->isExternal = $this->response->is_external; - $this->replaceChannel = property_exists($this->response, 'replace_channel') ? new Channel($client, - $this->response->replace_channel) : null; - $this->result = $this->response->result; - $this->transferTarget = property_exists($this->response, 'transfer_target') ? new Channel($client, - $this->response->transfer_target) : null; - $this->transferee = property_exists($this->response, 'transferee') ? new Channel($client, - $this->response->transferee) : null; - $this->transfererFirstLeg = new Channel($client, $this->response->transferer_first_leg); - $this->transfererFirstLegBridge = property_exists($this->response, - 'transferer_first_leg_bridge') ? new Bridge($client, $this->response->transferer_first_leg_bridge) : null; - $this->transfererSecondLeg = new Channel($client, $this->response->transferer_second_leg); - $this->transfererSecondLegBridge = property_exists($this->response, - 'transferer_second_leg_bridge') ? new Bridge($client, $this->response->transferer_second_leg_bridge) : null; + $this->destinationApplication = $this->getResponseValue('destination_application'); + $this->destinationBridge = $this->getResponseValue('destination_bridge'); + $this->destinationLinkFirstLeg = $this->getResponseValue('destination_link_first_leg', + '\phparia\Resources\Channel', $client); + $this->destinationLinkSecondLeg = $this->getResponseValue('destination_link_second_leg'); + $this->destinationThreewayBridge = $this->getResponseValue('destination_threeway_bridge', + '\phparia\Resources\Bridge', $client); + $this->destinationThreewayChannel = $this->getResponseValue('destination_threeway_channel', + '\phparia\Resources\Channel', $client); + $this->destinationType = $this->getResponseValue('destination_type'); + $this->isExternal = $this->getResponseValue('is_external'); + $this->replaceChannel = $this->getResponseValue('replace_channel', '\phparia\Resources\Channel', $client); + $this->result = $this->getResponseValue('result'); + $this->transferTarget = $this->getResponseValue('transfer_target', '\phparia\Resources\Channel', $client); + $this->transferee = $this->getResponseValue('transferee', '\phparia\Resources\Channel', $client); + $this->transfererFirstLeg = $this->getResponseValue('transferer_first_leg', '\phparia\Resources\Channel', + $client); + $this->transfererFirstLegBridge = $this->getResponseValue('transferer_first_leg_bridge', + '\phparia\Resources\Bridge', $client); + $this->transfererSecondLeg = $this->getResponseValue('transferer_second_leg', '\phparia\Resources\Channel', + $client); + $this->transfererSecondLegBridge = $this->getResponseValue('transferer_second_leg_bridge', + '\phparia\Resources\Bridge', $client); } - } diff --git a/src/wormling/phparia/Events/BridgeBlindTransfer.php b/src/wormling/phparia/Events/BridgeBlindTransfer.php index d9d37d9..9927930 100644 --- a/src/wormling/phparia/Events/BridgeBlindTransfer.php +++ b/src/wormling/phparia/Events/BridgeBlindTransfer.php @@ -27,7 +27,7 @@ * * @author Brian Smith */ -class BridgeBlindTransfer extends Event +class BridgeBlindTransfer extends BridgeTransfer { /** * @var Bridge (optional) - The bridge being transferred @@ -141,17 +141,13 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->bridge = property_exists($this->response, 'bridge') ? new Bridge($client, - $this->response->bridge) : null; - $this->channel = new Channel($client, $this->response->channel); - $this->contex = $this->response->context; - $this->exten = $this->response->exten; - $this->isExternal = $this->response->is_external; - $this->replaceChannel = property_exists($this->response, 'replace_channel') ? new Channel($client, - $this->response->replace_channel) : null; - $this->result = $this->response->result; - $this->transferee = property_exists($this->response, 'transferee') ? new Channel($client, - $this->response->transferee) : null; + $this->bridge = $this->getResponseValue('bridge', '\phparia\Resources\Bridge', $client); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->contex = $this->getResponseValue('context'); + $this->exten = $this->getResponseValue('exten'); + $this->isExternal = $this->getResponseValue('is_external'); + $this->replaceChannel = $this->getResponseValue('replace_channel', '\phparia\Resources\Channel', $client); + $this->result = $this->getResponseValue('result'); + $this->transferee = $this->getResponseValue('transferee', '\phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/BridgeCreated.php b/src/wormling/phparia/Events/BridgeCreated.php index a53c1b6..2cb7920 100644 --- a/src/wormling/phparia/Events/BridgeCreated.php +++ b/src/wormling/phparia/Events/BridgeCreated.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->bridge = new Bridge($client, $this->response->bridge); + $this->bridge = $this->getResponseValue('bridge', '\phparia\Resources\Bridge', $client); } - } diff --git a/src/wormling/phparia/Events/BridgeDestroyed.php b/src/wormling/phparia/Events/BridgeDestroyed.php index ca42fcf..bd4f996 100644 --- a/src/wormling/phparia/Events/BridgeDestroyed.php +++ b/src/wormling/phparia/Events/BridgeDestroyed.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->bridge = new Bridge($client, $this->response->bridge); + $this->bridge = $this->getResponseValue('bridge', '\phparia\Resources\Bridge', $client); } - } diff --git a/src/wormling/phparia/Events/BridgeMerged.php b/src/wormling/phparia/Events/BridgeMerged.php index 3b2d097..54d2f57 100644 --- a/src/wormling/phparia/Events/BridgeMerged.php +++ b/src/wormling/phparia/Events/BridgeMerged.php @@ -67,8 +67,7 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->bridge = new Bridge($client, $this->response->bridge); - $this->bridgeFrom = new Bridge($client, $this->response->bridge_from); + $this->bridge = $this->getResponseValue('bridge', '\phparia\Resources\Bridge', $client); + $this->bridgeFrom = $this->getResponseValue('bridge_from', '\phparia\Resources\Bridge', $client); } - } diff --git a/src/wormling/phparia/Events/ChannelCallerId.php b/src/wormling/phparia/Events/ChannelCallerId.php index 9ab65c5..95b815b 100644 --- a/src/wormling/phparia/Events/ChannelCallerId.php +++ b/src/wormling/phparia/Events/ChannelCallerId.php @@ -80,9 +80,8 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->callerPresentation = $this->response->caller_presentation; - $this->callerPresentationTxt = $this->response->caller_presentation_txt; - $this->channel = new Channel($client, $this->response->channel); + $this->callerPresentation = $this->getResponseValue('caller_presentation'); + $this->callerPresentationTxt = $this->getResponseValue('caller_presentation_txt'); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/ChannelConnectedLine.php b/src/wormling/phparia/Events/ChannelConnectedLine.php index e30df8f..d453178 100644 --- a/src/wormling/phparia/Events/ChannelConnectedLine.php +++ b/src/wormling/phparia/Events/ChannelConnectedLine.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = new Channel($client, $this->response->channel); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/ChannelCreated.php b/src/wormling/phparia/Events/ChannelCreated.php index 9ba71b5..84a83c5 100644 --- a/src/wormling/phparia/Events/ChannelCreated.php +++ b/src/wormling/phparia/Events/ChannelCreated.php @@ -54,7 +54,7 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = new Channel($client, $this->response->channel); + $this->channel = $this->getResponseValue('channel', 'phparia\Resources\Channel', $client); } } diff --git a/src/wormling/phparia/Events/ChannelDestroyed.php b/src/wormling/phparia/Events/ChannelDestroyed.php index 48fdb59..1d2b855 100644 --- a/src/wormling/phparia/Events/ChannelDestroyed.php +++ b/src/wormling/phparia/Events/ChannelDestroyed.php @@ -126,9 +126,9 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->cause = $this->response->cause; - $this->causeTxt = $this->response->cause_txt; - $this->channel = new Channel($client, $this->response->channel); + $this->cause = $this->getResponseValue('cause'); + $this->causeTxt = $this->getResponseValue('cause_txt'); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); } } diff --git a/src/wormling/phparia/Events/ChannelDialplan.php b/src/wormling/phparia/Events/ChannelDialplan.php index 9c8eb57..b287c39 100644 --- a/src/wormling/phparia/Events/ChannelDialplan.php +++ b/src/wormling/phparia/Events/ChannelDialplan.php @@ -80,8 +80,8 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = new Channel($client, $this->response->channel); - $this->dialplanApp = $this->response->dialplan_app; - $this->dialplanAppData = $this->response->dialplan_app_data; + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->dialplanApp = $this->getResponseValue('dialplan_app'); + $this->dialplanAppData = $this->getResponseValue('dialplan_app_data'); } } diff --git a/src/wormling/phparia/Events/ChannelDtmfReceived.php b/src/wormling/phparia/Events/ChannelDtmfReceived.php index 189798b..6f96cbc 100644 --- a/src/wormling/phparia/Events/ChannelDtmfReceived.php +++ b/src/wormling/phparia/Events/ChannelDtmfReceived.php @@ -81,9 +81,9 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = new Channel($client, $this->response->channel); - $this->digit = $this->response->digit; - $this->durationMs = $this->response->duration_ms; + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->digit = $this->getResponseValue('digit'); + $this->durationMs = $this->getResponseValue('duration_ms'); } } diff --git a/src/wormling/phparia/Events/ChannelEnteredBridge.php b/src/wormling/phparia/Events/ChannelEnteredBridge.php index 95721d7..fa4375c 100644 --- a/src/wormling/phparia/Events/ChannelEnteredBridge.php +++ b/src/wormling/phparia/Events/ChannelEnteredBridge.php @@ -68,8 +68,7 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->bridge = new Bridge($client, $this->response->bridge); - $this->channel = new Channel($client, $this->response->channel); + $this->bridge = $this->getResponseValue('bridge', '\phparia\Resources\Bridge', $client); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/ChannelHangupRequest.php b/src/wormling/phparia/Events/ChannelHangupRequest.php index 2d82524..d352e99 100644 --- a/src/wormling/phparia/Events/ChannelHangupRequest.php +++ b/src/wormling/phparia/Events/ChannelHangupRequest.php @@ -81,9 +81,8 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->cause = property_exists($this->response, 'cause') ? $this->response->cause : null; - $this->channel = new Channel($client, $this->response->channel); - $this->soft = property_exists($this->response, 'soft') ? $this->response->soft : null; + $this->cause = $this->getResponseValue('cause'); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->soft = $this->getResponseValue('soft'); } - } diff --git a/src/wormling/phparia/Events/ChannelLeftBridge.php b/src/wormling/phparia/Events/ChannelLeftBridge.php index b862b1f..1e7d797 100644 --- a/src/wormling/phparia/Events/ChannelLeftBridge.php +++ b/src/wormling/phparia/Events/ChannelLeftBridge.php @@ -68,8 +68,7 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->bridge = new Bridge($client, $this->response->bridge); - $this->channel = new Channel($client, $this->response->channel); + $this->bridge = $this->getResponseValue('bridge', '\phparia\Resources\Bridge', $client); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/ChannelStateChange.php b/src/wormling/phparia/Events/ChannelStateChange.php index 1a914f6..56db3f7 100644 --- a/src/wormling/phparia/Events/ChannelStateChange.php +++ b/src/wormling/phparia/Events/ChannelStateChange.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = new Channel($client, $this->response->channel); + $this->channel = $this->getResponseValue('channel', 'phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/ChannelTalkingFinished.php b/src/wormling/phparia/Events/ChannelTalkingFinished.php index e162e0a..eacbc0d 100644 --- a/src/wormling/phparia/Events/ChannelTalkingFinished.php +++ b/src/wormling/phparia/Events/ChannelTalkingFinished.php @@ -67,8 +67,7 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = new Channel($client, $this->response->channel); - $this->duration = $this->response->duration; + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->duration = $this->getResponseValue('duration'); } - } diff --git a/src/wormling/phparia/Events/ChannelTalkingStarted.php b/src/wormling/phparia/Events/ChannelTalkingStarted.php index 2134478..3750fa7 100644 --- a/src/wormling/phparia/Events/ChannelTalkingStarted.php +++ b/src/wormling/phparia/Events/ChannelTalkingStarted.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = new Channel($client, $this->response->channel); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/ChannelUserevent.php b/src/wormling/phparia/Events/ChannelUserevent.php index 1d67758..d47e99f 100644 --- a/src/wormling/phparia/Events/ChannelUserevent.php +++ b/src/wormling/phparia/Events/ChannelUserevent.php @@ -19,9 +19,6 @@ namespace phparia\Events; use phparia\Client\AriClient; -use phparia\Resources\Bridge; -use phparia\Resources\Channel; -use phparia\Resources\Endpoint; /** * User-generated event with additional user-defined fields in the object. @@ -103,14 +100,10 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->bridge = property_exists($this->response, 'bridge') ? new Bridge($client, - $this->response->bridge) : null; - $this->channel = property_exists($this->response, 'channel') ? new Channel($client, - $this->response->channel) : null; - $this->endpoint = property_exists($this->response, 'endpoint') ? new Endpoint($client, - $this->response->endpoint) : null; - $this->eventname = $this->response->eventname; - $this->userevent = $this->response->userevent; + $this->bridge = $this->getResponseValue('bridge', '\phparia\Resources\Bridge', $client); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->endpoint = $this->getResponseValue('endpoint', '\phparia\Resources\Endpoint', $client); + $this->eventname = $this->getResponseValue('eventname'); + $this->userevent = $this->getResponseValue('userevent'); } - } diff --git a/src/wormling/phparia/Events/ChannelVarset.php b/src/wormling/phparia/Events/ChannelVarset.php index ace8846..385f584 100644 --- a/src/wormling/phparia/Events/ChannelVarset.php +++ b/src/wormling/phparia/Events/ChannelVarset.php @@ -80,10 +80,8 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = property_exists($this->response, 'channel') ? new Channel($client, - $this->response->channel) : null; - $this->value = property_exists($this->response, 'value') ? $this->response->value : null; - $this->variable = property_exists($this->response, 'variable') ? $this->response->variable : null; + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->value = $this->getResponseValue('value'); + $this->variable = $this->getResponseValue('variable'); } - } diff --git a/src/wormling/phparia/Events/DeviceStateChange.php b/src/wormling/phparia/Events/DeviceStateChange.php index d93d533..d9aa5c9 100644 --- a/src/wormling/phparia/Events/DeviceStateChange.php +++ b/src/wormling/phparia/Events/DeviceStateChange.php @@ -49,7 +49,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->deviceState = new DeviceState($client, $this->response->device_state); + $this->deviceState = $this->getResponseValue('device_state', '\phparia\Resources\DeviceState', $client); } - } diff --git a/src/wormling/phparia/Events/Dial.php b/src/wormling/phparia/Events/Dial.php index ac0194e..3559962 100644 --- a/src/wormling/phparia/Events/Dial.php +++ b/src/wormling/phparia/Events/Dial.php @@ -127,14 +127,11 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->caller = property_exists($this->response, 'channel') ? new Channel($client, - $this->response->caller) : null; - $this->dialstatus = $this->response->dialstatus; - $this->dialstring = property_exists($this->response, 'dialstring') ? $this->response->dialstring : null; - $this->forward = property_exists($this->response, 'forward') ? $this->response->forward : null; - $this->forwarded = property_exists($this->response, 'forwarded') ? new Channel($client, - $this->response->forwarded) : null; - $this->peer = $this->response->peer; + $this->caller = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->dialstatus = $this->getResponseValue('dialstatus'); + $this->dialstring = $this->getResponseValue('dialstring'); + $this->forward = $this->getResponseValue('forward'); + $this->forwarded = $this->getResponseValue('forwarded', '\phparia\Resources\Channel', $client); + $this->peer = $this->getResponseValue('peer'); } - } diff --git a/src/wormling/phparia/Events/EndpointStateChange.php b/src/wormling/phparia/Events/EndpointStateChange.php index 7e29d97..d00b22d 100644 --- a/src/wormling/phparia/Events/EndpointStateChange.php +++ b/src/wormling/phparia/Events/EndpointStateChange.php @@ -49,7 +49,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->endpoint = new Endpoint($client, $this->response->endpoint); + $this->endpoint = $this->getResponseValue('endpoint', '\phparia\Resources\Endpoint', $client); } - } diff --git a/src/wormling/phparia/Events/Event.php b/src/wormling/phparia/Events/Event.php index aa7e013..993e860 100644 --- a/src/wormling/phparia/Events/Event.php +++ b/src/wormling/phparia/Events/Event.php @@ -102,9 +102,7 @@ public function __construct(AriClient $client, $response) parent::__construct($response); - $this->application = $this->response->application; - $this->timestamp = property_exists($this->response, - 'timestamp') ? new \DateTime($this->response->timestamp) : null; + $this->application = $this->getResponseValue('application'); + $this->timestamp = $this->getResponseValue('timestamp', '\DateTime'); } - } diff --git a/src/wormling/phparia/Events/Message.php b/src/wormling/phparia/Events/Message.php index ad2f83d..96b8af7 100644 --- a/src/wormling/phparia/Events/Message.php +++ b/src/wormling/phparia/Events/Message.php @@ -44,7 +44,6 @@ public function __construct($response) { parent::__construct($response); - $this->type = $this->response->type; + $this->type = $this->getResponseValue('type'); } - } diff --git a/src/wormling/phparia/Events/PlaybackFinished.php b/src/wormling/phparia/Events/PlaybackFinished.php index aed62d9..7eb6864 100644 --- a/src/wormling/phparia/Events/PlaybackFinished.php +++ b/src/wormling/phparia/Events/PlaybackFinished.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->playback = new Playback($client, $this->response->playback); + $this->playback = $this->getResponseValue('playback', '\phparia\Resources\Playback', $client); } - } diff --git a/src/wormling/phparia/Events/PlaybackStarted.php b/src/wormling/phparia/Events/PlaybackStarted.php index 44e7d20..726d8f9 100644 --- a/src/wormling/phparia/Events/PlaybackStarted.php +++ b/src/wormling/phparia/Events/PlaybackStarted.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->playback = new Playback($client, $this->response->playback); + $this->playback = $this->getResponseValue('playback', '\phparia\Resources\Playback', $client); } - } diff --git a/src/wormling/phparia/Events/RecordingFailed.php b/src/wormling/phparia/Events/RecordingFailed.php index 60a7c8a..8a26622 100644 --- a/src/wormling/phparia/Events/RecordingFailed.php +++ b/src/wormling/phparia/Events/RecordingFailed.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->recording = new LiveRecording($client, $this->response->recording); + $this->recording = $this->getResponseValue('recording', '\phparia\Resources\LiveRecording', $client); } - } diff --git a/src/wormling/phparia/Events/RecordingFinished.php b/src/wormling/phparia/Events/RecordingFinished.php index 30c392d..f588567 100644 --- a/src/wormling/phparia/Events/RecordingFinished.php +++ b/src/wormling/phparia/Events/RecordingFinished.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->recording = new LiveRecording($client, $this->response->recording); + $this->recording = $this->getResponseValue('recording', '\phparia\Resources\LiveRecording', $client); } - } diff --git a/src/wormling/phparia/Events/RecordingStarted.php b/src/wormling/phparia/Events/RecordingStarted.php index 73b9a92..dbfc873 100644 --- a/src/wormling/phparia/Events/RecordingStarted.php +++ b/src/wormling/phparia/Events/RecordingStarted.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->recording = new LiveRecording($client, $this->response->recording); + $this->recording = $this->getResponseValue('recording', '\phparia\Resources\LiveRecording', $client); } - } diff --git a/src/wormling/phparia/Events/StasisEnd.php b/src/wormling/phparia/Events/StasisEnd.php index a978470..dd6ce51 100644 --- a/src/wormling/phparia/Events/StasisEnd.php +++ b/src/wormling/phparia/Events/StasisEnd.php @@ -54,7 +54,6 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->channel = new Channel($client, $this->response->channel); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/StasisStart.php b/src/wormling/phparia/Events/StasisStart.php index ec4810e..7934897 100644 --- a/src/wormling/phparia/Events/StasisStart.php +++ b/src/wormling/phparia/Events/StasisStart.php @@ -80,10 +80,8 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->args = $this->response->args; - $this->channel = new Channel($client, $this->response->channel); - $this->replaceChannel = property_exists($this->response, 'replace_channel') ? new Channel($client, - $this->response->replace_channel) : null; + $this->args = $this->getResponseValue('args'); + $this->channel = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client); + $this->replaceChannel = $this->getResponseValue('replace_channel', '\phparia\Resources\Channel', $client); } - } diff --git a/src/wormling/phparia/Events/TextMessageReceived.php b/src/wormling/phparia/Events/TextMessageReceived.php index a92a78e..108c58a 100644 --- a/src/wormling/phparia/Events/TextMessageReceived.php +++ b/src/wormling/phparia/Events/TextMessageReceived.php @@ -60,9 +60,7 @@ public function __construct(AriClient $client, $response) { parent::__construct($client, $response); - $this->endpoint = property_exists($this->response, 'endpoint') ? new Endpoint($client, - $this->response->endpoint) : null; - $this->message = new TextMessage($this->response->message); + $this->endpoint = $this->getResponseValue('endpoint', '\phparia\Resources\Endpoint', $client); + $this->message = $this->getResponseValue('message', '\phparia\Resources\TextMessage'); } - }