public function add($key, $value = null)
	{
		// Test whether this key is already in use
		if ($this->exists($key))
		{
			// If the action is "ignore" we return the old value, if it's "error" we throw an
			// exception. Otherwise, we keep going and replace the value
			if ($this->onDuplicateAction === 'ignore')
			{
				return $this->get($key);
			}
			elseif ($this->onDuplicateAction === 'error')
			{
				throw $this->getAlreadyExistsException($key);
			}
		}

		return $this->set($key, $value);
	}
public function add($key, $value = null)
	{
		// Test whether this key is already in use
		if ($this->exists($key))
		{
			// If the action is "ignore" we return the old value, if it's "error" we throw an
			// exception. Otherwise, we keep going and replace the value
			if ($this->onDuplicateAction === 'ignore')
			{
				return $this->get($key);
			}
			elseif ($this->onDuplicateAction === 'error')
			{
				throw $this->getAlreadyExistsException($key);
			}
		}

		return $this->set($key, $value);
	}
public function add ( $ key , $ value = null ) { // Test whether this key is already in use if ( $ this -> exists ( $ key ) ) { // If the action is "ignore" we return the old value, if it's "error" we throw an // exception. Otherwise, we keep going and replace the value if ( $ this -> onDuplicateAction === 'ignore' ) { return $ this -> get ( $ key ) ; } elseif ( $ this -> onDuplicateAction === 'error' ) { throw $ this -> getAlreadyExistsException ( $ key ) ; } } return $ this -> set ( $ key , $ value ) ; }
Add an item to this collection

NOTE: relies on exists() to check the key for invalid values and on set() to normalize it

@param  string $key   Item's key
@param  mixed  $value Item's value
@return mixed         Normalized value
Add an item to this collection