public function newFromArray( array $diffOp ) {
		$this->assertHasKey( 'type', $diffOp );

		if ( $diffOp['type'] === 'add' ) {
			$this->assertHasKey( 'newvalue', $diffOp );
			return new DiffOpAdd( $this->arrayToObject( $diffOp['newvalue'] ) );
		}

		if ( $diffOp['type'] === 'remove' ) {
			$this->assertHasKey( 'oldvalue', $diffOp );
			return new DiffOpRemove( $this->arrayToObject( $diffOp['oldvalue'] ) );
		}

		if ( $diffOp['type'] === 'change' ) {
			$this->assertHasKey( 'newvalue', $diffOp );
			$this->assertHasKey( 'oldvalue', $diffOp );
			return new DiffOpChange(
				$this->arrayToObject( $diffOp['oldvalue'] ),
				$this->arrayToObject( $diffOp['newvalue'] ) );
		}

		if ( $diffOp['type'] === 'diff' ) {
			$this->assertHasKey( 'operations', $diffOp );
			$this->assertHasKey( 'isassoc', $diffOp );

			$operations = [];

			foreach ( $diffOp['operations'] as $key => $operation ) {
				$operations[$key] = $this->newFromArray( $operation );
			}

			return new Diff( $operations, $diffOp['isassoc'] );
		}

		throw new InvalidArgumentException( 'Invalid array provided. Unknown type' );
	}
public function newFromArray( array $diffOp ) {
		$this->assertHasKey( 'type', $diffOp );

		if ( $diffOp['type'] === 'add' ) {
			$this->assertHasKey( 'newvalue', $diffOp );
			return new DiffOpAdd( $this->arrayToObject( $diffOp['newvalue'] ) );
		}

		if ( $diffOp['type'] === 'remove' ) {
			$this->assertHasKey( 'oldvalue', $diffOp );
			return new DiffOpRemove( $this->arrayToObject( $diffOp['oldvalue'] ) );
		}

		if ( $diffOp['type'] === 'change' ) {
			$this->assertHasKey( 'newvalue', $diffOp );
			$this->assertHasKey( 'oldvalue', $diffOp );
			return new DiffOpChange(
				$this->arrayToObject( $diffOp['oldvalue'] ),
				$this->arrayToObject( $diffOp['newvalue'] ) );
		}

		if ( $diffOp['type'] === 'diff' ) {
			$this->assertHasKey( 'operations', $diffOp );
			$this->assertHasKey( 'isassoc', $diffOp );

			$operations = [];

			foreach ( $diffOp['operations'] as $key => $operation ) {
				$operations[$key] = $this->newFromArray( $operation );
			}

			return new Diff( $operations, $diffOp['isassoc'] );
		}

		throw new InvalidArgumentException( 'Invalid array provided. Unknown type' );
	}
public function newFromArray ( array $ diffOp ) { $ this -> assertHasKey ( 'type' , $ diffOp ) ; if ( $ diffOp [ 'type' ] === 'add' ) { $ this -> assertHasKey ( 'newvalue' , $ diffOp ) ; return new DiffOpAdd ( $ this -> arrayToObject ( $ diffOp [ 'newvalue' ] ) ) ; } if ( $ diffOp [ 'type' ] === 'remove' ) { $ this -> assertHasKey ( 'oldvalue' , $ diffOp ) ; return new DiffOpRemove ( $ this -> arrayToObject ( $ diffOp [ 'oldvalue' ] ) ) ; } if ( $ diffOp [ 'type' ] === 'change' ) { $ this -> assertHasKey ( 'newvalue' , $ diffOp ) ; $ this -> assertHasKey ( 'oldvalue' , $ diffOp ) ; return new DiffOpChange ( $ this -> arrayToObject ( $ diffOp [ 'oldvalue' ] ) , $ this -> arrayToObject ( $ diffOp [ 'newvalue' ] ) ) ; } if ( $ diffOp [ 'type' ] === 'diff' ) { $ this -> assertHasKey ( 'operations' , $ diffOp ) ; $ this -> assertHasKey ( 'isassoc' , $ diffOp ) ; $ operations = [ ] ; foreach ( $ diffOp [ 'operations' ] as $ key => $ operation ) { $ operations [ $ key ] = $ this -> newFromArray ( $ operation ) ; } return new Diff ( $ operations , $ diffOp [ 'isassoc' ] ) ; } throw new InvalidArgumentException ( 'Invalid array provided. Unknown type' ) ; }
Returns an instance of DiffOp constructed from the provided array.

This roundtrips with @see DiffOp::toArray.

@since 0.5

@param array $diffOp

@return DiffOp\DiffOp
@throws InvalidArgumentException
Returns an instance of DiffOp constructed from the provided array .