src/Bandolier/Type/Collection.php
public function addItem($obj, $key = null)
    {
        if ($key == null) {
            $this->items[] = $obj;
        } else {
            if (array_key_exists($key, $this->getItems())) {
                throw new KeyHasUseException("Key $key already in use.");
            } else {
                $this->items[$key] = $obj;
            }
        }

        return $this;
    }
public function addItem($obj, $key = null)
    {
        if ($key == null) {
            $this->items[] = $obj;
        } else {
            if (array_key_exists($key, $this->getItems())) {
                throw new KeyHasUseException("Key $key already in use.");
            } else {
                $this->items[$key] = $obj;
            }
        }

        return $this;
    }
public function addItem ( $ obj , $ key = null ) { if ( $ key == null ) { $ this -> items [ ] = $ obj ; } else { if ( array_key_exists ( $ key , $ this -> getItems ( ) ) ) { throw new KeyHasUseException ( "Key $key already in use." ) ; } else { $ this -> items [ $ key ] = $ obj ; } } return $ this ; }
Add an item to the collection by key
@param $obj
@param null|string|int $key
@return $this
@throws KeyHasUseException
Add an item to the collection by key