Example #1
0
 /**
  * Returns the index of the first occurrence of the specified element,
  * or FALSE if this collection does not contain this element.
  * @param  mixed
  * @return int|FALSE
  * @throws InvalidArgumentException
  */
 protected function search($item)
 {
     if (is_object($item)) {
         $key = spl_object_hash($item);
         return parent::offsetExists($key) ? $key : FALSE;
     } else {
         return array_search($item, $this->getArrayCopy(), TRUE);
     }
 }
Example #2
0
 public function offsetExists($offset)
 {
     $this->load();
     return parent::offsetExists($offset);
 }
Example #3
0
 /**
  * Removes the element at the specified position in this list.
  * @param  string key
  * @return void
  * @throws NotSupportedException, \InvalidArgumentException
  */
 public function offsetUnset($key)
 {
     if (!is_scalar($key)) {
         throw new InvalidArgumentException("Key must be either a string or an integer, " . gettype($key) . " given.");
     }
     $this->beforeRemove();
     if (parent::offsetExists($key)) {
         parent::offsetUnset($key);
     }
 }
Example #4
0
 /**
  * Exists item? (\ArrayAccess implementation).
  *
  * @param  int index
  *
  * @return bool
  */
 public function offsetExists($index)
 {
     if (!$this->isLoaded() && $this->isLoadable()) {
         $this->load();
     }
     return parent::offsetExists($index);
 }