| Total Complexity | 4 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 93.33% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class EntityTypeAwareDiffOpFactory extends DiffOpFactory { |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param array $diffOp |
||
| 21 | * |
||
| 22 | * @return DiffOp |
||
| 23 | * @throws InvalidArgumentException |
||
| 24 | */ |
||
| 25 | 3 | public function newFromArray( array $diffOp ) { |
|
| 26 | 3 | $this->assertHasKey( 'type', $diffOp ); |
|
| 27 | |||
| 28 | // see EntityDiff::getType() and ItemDiff::getType() |
||
| 29 | 2 | if ( preg_match( '!^diff/(.*)$!', $diffOp['type'], $matches ) ) { |
|
| 30 | 1 | $itemType = $matches[1]; |
|
| 31 | 1 | $this->assertHasKey( 'operations', $diffOp ); |
|
| 32 | |||
| 33 | 1 | $operations = $this->createOperations( $diffOp['operations'] ); |
|
| 34 | 1 | $diff = EntityDiff::newForType( $itemType, $operations ); |
|
| 35 | |||
| 36 | 1 | return $diff; |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | return parent::newFromArray( $diffOp ); |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Converts a list of diff operations represented by arrays into a list of |
||
| 44 | * DiffOp objects. |
||
| 45 | * |
||
| 46 | * @param array $data the input data |
||
| 47 | * @return DiffOp[] The diff ops |
||
| 48 | */ |
||
| 49 | 1 | private function createOperations( array $data ) { |
|
| 57 | } |
||
| 58 | |||
| 60 |