/** * @see Collection::drop() * * @observable "collection:<type>:drop:invoke"( object $collectible ) * @observable "collection:<type>:drop:except"( Throwable $e ) */ public function drop($collectible) { if (!$collectible instanceof $this->_type) { if (is_callable($collectible)) { foreach ($this->filter($collectible) as $member) { $this->drop($member); } return; } $t = Vars::type($collectible); $m = "\$collectible must be a collectible object or filter callback; [{$t}] provided"; throw new \TypeError($m, E_USER_WARNING); } try { $this->notify("collection:{$this->_type}:drop:invoke", $collectible); $key = array_search($collectible, $this->_collection); if ($key === false) { throw new CollectionException(CollectionException::NOT_IN_COLLECTION); } unset($this->_collection[$key]); } catch (\Throwable $e) { $this->notify("collection:{$this->_type}:drop:except", $e); throw $e; } }