Skip to content

Commit

Permalink
Fixed checking existance of pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkgroenen committed Dec 14, 2015
1 parent 820d72e commit 917a6cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Pinterest/Models/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
30 changes: 21 additions & 9 deletions src/Pinterest/Transport/Response.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
<?php
/**
* Copyright 2015 Dirk Groenen
* Copyright 2015 Dirk Groenen
*
* (c) Dirk Groenen <dirk@bitlabs.nl>
*
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Expand All @@ -14,7 +14,7 @@
use DirkGroenen\Pinterest\Exceptions\PinterestException;

class Response {

/**
* Contains the raw response
*
Expand All @@ -24,14 +24,14 @@ class Response {

/**
* Used curl instance
*
*
* @var curl
*/
private $curl;

/**
* Constructor
*
*
* @param array $response
* @param CurlBuilder $curl
* @param curl $curl
Expand All @@ -48,7 +48,7 @@ public function __construct( $response, CurlBuilder $curl )

/**
* Decode the string to an array
*
*
* @access private
* @param string $response
* @return array
Expand All @@ -60,7 +60,7 @@ private function decodeString( $response )

/**
* Return the requested key data
*
*
* @access public
* @param string $key
* @return array
Expand All @@ -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
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/Pinterest/Endpoints/UsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 );
}

}

0 comments on commit 917a6cb

Please sign in to comment.