public function mergeAttributesRecursive($key, array $attributes)
    {

        // if the key not exists, simply add the new attributes
        if (!isset($this->attributes[$key])) {
            $this->attributes[$key] = $attributes;
            return;
        }

        // if the key exists and the value is an array, merge it with the passed array
        if (isset($this->attributes[$key]) && is_array($this->attributes[$key])) {
            $this->attributes[$key] = array_replace_recursive($this->attributes[$key], $attributes);
            return;
        }

        // throw an exception if the key exists, but the found value is not of type array
        throw new \Exception(sprintf('Can\'t merge attributes, because value for key %s already exists, but is not of type array', $key));
    }
public function mergeAttributesRecursive($key, array $attributes)
    {

        // if the key not exists, simply add the new attributes
        if (!isset($this->attributes[$key])) {
            $this->attributes[$key] = $attributes;
            return;
        }

        // if the key exists and the value is an array, merge it with the passed array
        if (isset($this->attributes[$key]) && is_array($this->attributes[$key])) {
            $this->attributes[$key] = array_replace_recursive($this->attributes[$key], $attributes);
            return;
        }

        // throw an exception if the key exists, but the found value is not of type array
        throw new \Exception(sprintf('Can\'t merge attributes, because value for key %s already exists, but is not of type array', $key));
    }
public function mergeAttributesRecursive ( $ key , array $ attributes ) { // if the key not exists, simply add the new attributes if ( ! isset ( $ this -> attributes [ $ key ] ) ) { $ this -> attributes [ $ key ] = $ attributes ; return ; } // if the key exists and the value is an array, merge it with the passed array if ( isset ( $ this -> attributes [ $ key ] ) && is_array ( $ this -> attributes [ $ key ] ) ) { $ this -> attributes [ $ key ] = array_replace_recursive ( $ this -> attributes [ $ key ] , $ attributes ) ; return ; } // throw an exception if the key exists, but the found value is not of type array throw new \ Exception ( sprintf ( 'Can\'t merge attributes, because value for key %s already exists, but is not of type array' , $ key ) ) ; }
This method merges the passed attributes with an array that
has already been added under the passed key.

If no value will be found under the passed key, the attributes
will simply be registered.

@param mixed $key        The key of the attributes that has to be merged with the passed ones
@param array $attributes The attributes that has to be merged with the exising ones

@return void
@throws \Exception Is thrown, if the already registered value is no array
@link http://php.net/array_replace_recursive
This method merges the passed attributes with an array that has already been added under the passed key .