Example #1
0
 public function testGetKey()
 {
     $item = new Item('key', $this->storage);
     $this->assertEquals('key', $item->getKey());
 }
Example #2
0
 /**
  * Assert Item exists
  *
  * @param string itemKey
  * @return bool hasItem
  */
 public function hasItem($key, $isKey = true)
 {
     if (!$isKey) {
         if ($key instanceof Item) {
             $key = Item::getKey($key->getId());
         } else {
             $key = Item::getKey($key);
         }
     }
     return isset($this->_items[$key]);
 }
Example #3
0
 /**
  * Remove an Item from this Discount
  *
  * @param string
  * @return Discount
  */
 public function unsetItem($key)
 {
     if ($key instanceof Item) {
         $key = Item::getKey($key->getId());
     }
     if (!count($this->getItems())) {
         return $this;
     }
     $newItems = array_flip($this->getItems());
     unset($newItems[$key]);
     $newItems = array_flip($newItems);
     $this->_items = $newItems;
     return $this;
 }