Merge pull request #41 from ryansundberg/master

Added add/remove/isEmpty methods to ItemList
This commit is contained in:
Avi (Ananya) Das
2014-05-01 10:17:22 -05:00

View File

@@ -5,6 +5,21 @@ use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class ItemList extends PPModel {
/**
* Construct an empty list.
*/
function __construct() {
$this->items = array();
}
/**
* Is this list empty?
*/
public function isEmpty() {
return empty($this->items);
}
/**
* List of items.
*
@@ -25,6 +40,26 @@ class ItemList extends PPModel {
return $this->items;
}
/**
* Append an item to the list.
* @return PayPal\Api\Item
*/
public function addItem($item) {
return $this->setItems(
array_merge($this->items, array($item))
);
}
/**
* Remove an item from the list.
* Items are compared using === comparision (PHP.net)
* @return PayPal\Api\Item
*/
public function removeItem($item) {
return $this->setItems(
array_diff($this->items, array($item))
);
}
/**
* Shipping address.