1 | <?php |
||
26 | class MapDiffer implements Differ { |
||
27 | |||
28 | /** |
||
29 | * @var bool |
||
30 | */ |
||
31 | private $recursively; |
||
32 | |||
33 | /** |
||
34 | * @var Differ |
||
35 | */ |
||
36 | private $listDiffer; |
||
37 | |||
38 | /** |
||
39 | * @var ValueComparer |
||
40 | */ |
||
41 | private $valueComparer; |
||
42 | |||
43 | /** |
||
44 | * The third argument ($comparer) was added in 3.0 |
||
45 | */ |
||
46 | 27 | public function __construct( bool $recursively = false, Differ $listDiffer = null, ValueComparer $comparer = null ) { |
|
51 | |||
52 | /** |
||
53 | * @see Differ::doDiff |
||
54 | * |
||
55 | * Computes the diff between two associate arrays. |
||
56 | * |
||
57 | * @since 0.4 |
||
58 | * |
||
59 | * @param array $oldValues The first array |
||
60 | * @param array $newValues The second array |
||
61 | * |
||
62 | * @throws Exception |
||
63 | * @return DiffOp[] |
||
64 | */ |
||
65 | 27 | public function doDiff( array $oldValues, array $newValues ): array { |
|
81 | |||
82 | 27 | private function getAllKeys( $oldSet, $newSet ): array { |
|
88 | |||
89 | 18 | private function getDiffOpForElement( $key, array $oldSet, array $newSet ) { |
|
120 | |||
121 | 10 | private function getDiffOpForElementRecursively( $key, array $oldSet, array $newSet ) { |
|
131 | |||
132 | 10 | private function getDiffForArrays( array $old, array $new ): Diff { |
|
140 | |||
141 | /** |
||
142 | * Returns if an array is associative or not. |
||
143 | * |
||
144 | * @param array $array |
||
145 | * |
||
146 | * @return bool |
||
147 | */ |
||
148 | 10 | private function isAssociative( array $array ): bool { |
|
157 | |||
158 | /** |
||
159 | * Similar to the native array_diff_assoc function, except that it will |
||
160 | * spot differences between array values. Very weird the native |
||
161 | * function just ignores these... |
||
162 | * |
||
163 | * @see http://php.net/manual/en/function.array-diff-assoc.php |
||
164 | * |
||
165 | * @param array $from |
||
166 | * @param array $to |
||
167 | * |
||
168 | * @return array |
||
169 | */ |
||
170 | 27 | private function arrayDiffAssoc( array $from, array $to ): array { |
|
181 | |||
182 | } |
||
183 |