1 | <?php |
||
25 | class SyncOrderedIterator implements Iterator |
||
26 | { |
||
27 | const LEFT_MISSING = 'left-missing'; |
||
28 | const RIGHT_MISSING = 'right-missing'; |
||
29 | const EQUAL = 'equal'; |
||
30 | const NOT_EQUAL = 'not-equal'; |
||
31 | |||
32 | /** |
||
33 | * Left side iterator |
||
34 | * @var Iterator |
||
35 | */ |
||
36 | protected $left; |
||
37 | |||
38 | /** |
||
39 | * Right side iterator |
||
40 | * @var Iterator |
||
41 | */ |
||
42 | protected $right; |
||
43 | |||
44 | /** |
||
45 | * Current operation |
||
46 | * @var mixed |
||
47 | */ |
||
48 | protected $operation; |
||
49 | |||
50 | /** |
||
51 | * @var int |
||
52 | */ |
||
53 | protected $key = 0; |
||
54 | |||
55 | /** |
||
56 | * @var callable |
||
57 | */ |
||
58 | protected $keyCmpCallback; |
||
59 | /** |
||
60 | * @var callable |
||
61 | */ |
||
62 | protected $valueEqualsCallback; |
||
63 | |||
64 | /** |
||
65 | * SyncOrderedIterator constructor. |
||
66 | * |
||
67 | * @param Iterator $left |
||
68 | * @param Iterator $right |
||
69 | */ |
||
70 | 9 | public function __construct(Iterator $left, Iterator $right, |
|
78 | |||
79 | /** |
||
80 | * Return the current element |
||
81 | * @link http://php.net/manual/en/iterator.current.php |
||
82 | * @return mixed Can return any type. |
||
83 | * @since 5.0.0 |
||
84 | */ |
||
85 | 9 | public function current() |
|
89 | |||
90 | /** |
||
91 | * Move forward to next element |
||
92 | * @link http://php.net/manual/en/iterator.next.php |
||
93 | * @return void Any returned value is ignored. |
||
94 | * @since 5.0.0 |
||
95 | */ |
||
96 | 9 | public function next() |
|
145 | |||
146 | /** |
||
147 | * Return the key of the current element |
||
148 | * @link http://php.net/manual/en/iterator.key.php |
||
149 | * @return mixed scalar on success, or null on failure. |
||
150 | * @since 5.0.0 |
||
151 | */ |
||
152 | 9 | public function key() |
|
156 | |||
157 | /** |
||
158 | * Checks if current position is valid |
||
159 | * @link http://php.net/manual/en/iterator.valid.php |
||
160 | * @return boolean The return value will be casted to boolean and then evaluated. |
||
161 | * Returns true on success or false on failure. |
||
162 | * @since 5.0.0 |
||
163 | */ |
||
164 | 9 | public function valid() |
|
168 | |||
169 | /** |
||
170 | * Rewind the Iterator to the first element |
||
171 | * @link http://php.net/manual/en/iterator.rewind.php |
||
172 | * @return void Any returned value is ignored. |
||
173 | * @since 5.0.0 |
||
174 | */ |
||
175 | 9 | public function rewind() |
|
182 | |||
183 | /** |
||
184 | * Creates a operation for sync |
||
185 | * @param $operation string |
||
186 | * @return array|null |
||
187 | */ |
||
188 | 9 | protected function getOperation($operation) { |
|
220 | } |
||
221 |