diff --git a/src/Pinterest/Models/Collection.php b/src/Pinterest/Models/Collection.php index 4a8b54e..c1946db 100644 --- a/src/Pinterest/Models/Collection.php +++ b/src/Pinterest/Models/Collection.php @@ -87,7 +87,7 @@ public function __construct( Pinterest $master, $items, $model ){ $this->items = $this->buildCollectionModels($this->items); // Add pagination object - if( is_array($this->response->page) && !empty($this->response->page['next']) ){ + if( isset($this->response->page) && !empty($this->response->page['next']) ){ $this->pagination = $this->response->page; } else{ diff --git a/src/Pinterest/Transport/Response.php b/src/Pinterest/Transport/Response.php index a45497d..d2bcd06 100644 --- a/src/Pinterest/Transport/Response.php +++ b/src/Pinterest/Transport/Response.php @@ -1,9 +1,9 @@ - - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -14,7 +14,7 @@ use DirkGroenen\Pinterest\Exceptions\PinterestException; class Response { - + /** * Contains the raw response * @@ -24,14 +24,14 @@ class Response { /** * Used curl instance - * + * * @var curl */ private $curl; /** * Constructor - * + * * @param array $response * @param CurlBuilder $curl * @param curl $curl @@ -48,7 +48,7 @@ public function __construct( $response, CurlBuilder $curl ) /** * Decode the string to an array - * + * * @access private * @param string $response * @return array @@ -60,7 +60,7 @@ private function decodeString( $response ) /** * Return the requested key data - * + * * @access public * @param string $key * @return array @@ -70,9 +70,21 @@ public function __get($key) return $this->response[$key]; } + /** + * Return if the key is set + * + * @access public + * @param string $key + * @return array + */ + public function __isset($key) + { + return isset($this->response[$key]); + } + /** * Get the response code from the request - * + * * @access public * @return int */ diff --git a/tests/Pinterest/Endpoints/UsersTest.php b/tests/Pinterest/Endpoints/UsersTest.php index 9b9bcc0..c5ff6ed 100644 --- a/tests/Pinterest/Endpoints/UsersTest.php +++ b/tests/Pinterest/Endpoints/UsersTest.php @@ -113,6 +113,7 @@ public function testGetMeLikes() $this->assertInstanceOf( "DirkGroenen\Pinterest\Models\Collection", $response ); $this->assertInstanceOf( "DirkGroenen\Pinterest\Models\Pin", $response->get(0) ); + $this->assertFalse( $response->pagination ); } public function testGetMeFollowers() @@ -121,6 +122,7 @@ public function testGetMeFollowers() $this->assertInstanceOf( "DirkGroenen\Pinterest\Models\Collection", $response ); $this->assertInstanceOf( "DirkGroenen\Pinterest\Models\User", $response->get(0) ); + $this->assertNotFalse( $response->pagination ); } }