From 86ba9639c3bcfe6a229064de499e6a31128173c8 Mon Sep 17 00:00:00 2001 From: sonique6784 Date: Thu, 9 Oct 2014 14:03:47 +1100 Subject: [PATCH] improved getData() to give access to an attribut --- src/Traction/DynamicResponse.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Traction/DynamicResponse.php b/src/Traction/DynamicResponse.php index eccfb5d..5373a3d 100644 --- a/src/Traction/DynamicResponse.php +++ b/src/Traction/DynamicResponse.php @@ -22,10 +22,19 @@ public function __construct(TransportResponse $response) /** * get raw data array - * @return Array + * @param $attribute String attribute name + * + * @return Mixed */ - public function getData() { - return $this->data; + public function getData($attribute=null) { + if(isset($this->data)) { + if($attribute === null) { + return $this->data; + } else if(isset($this->data->$attribute)) { + return $this->data->$attribute; + } + } + return null; } /**