PayPal\Api\ItemList::removeItem PHP Method

removeItem() public method

Remove Items from the list.
public removeItem ( Item $item )
$item Item
    public function removeItem($item)
    {
        return $this->setItems(array_diff($this->getItems(), array($item)));
    }

Usage Example

コード例 #1
0
 public function testRemoveItemMethod()
 {
     $itemList = new ItemList();
     $item1 = ItemTest::createItem();
     $item1->setName("Name1");
     $item2 = ItemTest::createItem();
     $itemList->addItem($item1);
     $itemList->addItem($item2);
     $itemList->removeItem($item2);
     $this->assertEquals(sizeof($itemList->getItems()), 1);
     $remainingElements = $itemList->getItems();
     $this->assertEquals($remainingElements[0]->getName(), "Name1");
 }