Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ZObjectSlotDiffRenderer | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| getDiff | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| toDiffArray | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * WikiLambda ZObjectSlotDiffRenderer |
| 4 | * |
| 5 | * @file |
| 6 | * @ingroup Extensions |
| 7 | * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt |
| 8 | * @license MIT |
| 9 | */ |
| 10 | |
| 11 | namespace MediaWiki\Extension\WikiLambda\Diff; |
| 12 | |
| 13 | use MediaWiki\Content\Content; |
| 14 | use MediaWiki\Diff\SlotDiffRenderer; |
| 15 | use MediaWiki\Extension\WikiLambda\ZObjectContent; |
| 16 | |
| 17 | class ZObjectSlotDiffRenderer extends SlotDiffRenderer { |
| 18 | |
| 19 | /** |
| 20 | * @inheritDoc |
| 21 | */ |
| 22 | public function getDiff( |
| 23 | ?Content $oldContent = null, |
| 24 | ?Content $newContent = null |
| 25 | ) { |
| 26 | // Create the entrypoint differ ZObjectDiffer and call doDiff |
| 27 | $differ = new ZObjectDiffer(); |
| 28 | $diff = $differ->doDiff( |
| 29 | ( $oldContent === null ) ? [] : $this->toDiffArray( $oldContent ), |
| 30 | ( $newContent === null ) ? [] : $this->toDiffArray( $newContent ) |
| 31 | ); |
| 32 | |
| 33 | // TODO (T284473): Return string representation of the diff |
| 34 | return ''; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Helper function to extract and transform the data from content before |
| 39 | * calling the ZObjectDiffer::doDiff method. |
| 40 | * |
| 41 | * @param Content $content |
| 42 | * @return array |
| 43 | */ |
| 44 | private function toDiffArray( Content $content ): array { |
| 45 | '@phan-var ZObjectContent $content'; |
| 46 | return json_decode( json_encode( $content->getObject() ), true ); |
| 47 | } |
| 48 | } |