public function _mergeWithPrevious($previous)
    {
        if (!$previous)
        {
            return $this;
        }
        if ($previous instanceof DeleteOperation)
        {
            return new SetOperation($this->objects);
        }
        if ($previous instanceof SetOperation)
        {
            $oldValue = $previous->getValue();
            $result = $this->_apply($oldValue, null, null);

            return new SetOperation($result);
        }
        if ($previous instanceof AddUniqueOperation)
        {
            $oldList = $previous->getValue();
            $result = $this->_apply($oldList, null, null);

            return new AddUniqueOperation($result);
        }
        throw new AVException('Operation is invalid after previous operation.');
    }
public function _mergeWithPrevious($previous)
    {
        if (!$previous)
        {
            return $this;
        }
        if ($previous instanceof DeleteOperation)
        {
            return new SetOperation($this->objects);
        }
        if ($previous instanceof SetOperation)
        {
            $oldValue = $previous->getValue();
            $result = $this->_apply($oldValue, null, null);

            return new SetOperation($result);
        }
        if ($previous instanceof AddUniqueOperation)
        {
            $oldList = $previous->getValue();
            $result = $this->_apply($oldList, null, null);

            return new AddUniqueOperation($result);
        }
        throw new AVException('Operation is invalid after previous operation.');
    }
public function _mergeWithPrevious ( $ previous ) { if ( ! $ previous ) { return $ this ; } if ( $ previous instanceof DeleteOperation ) { return new SetOperation ( $ this -> objects ) ; } if ( $ previous instanceof SetOperation ) { $ oldValue = $ previous -> getValue ( ) ; $ result = $ this -> _apply ( $ oldValue , null , null ) ; return new SetOperation ( $ result ) ; } if ( $ previous instanceof AddUniqueOperation ) { $ oldList = $ previous -> getValue ( ) ; $ result = $ this -> _apply ( $ oldList , null , null ) ; return new AddUniqueOperation ( $ result ) ; } throw new AVException ( 'Operation is invalid after previous operation.' ) ; }
Merge this operation with the previous operation and return the result.

@param FieldOperation $previous Previous Operation.

@return FieldOperation Merged Operation.
@throws AVException
Merge this operation with the previous operation and return the result .