258 * This is here only for debugging purposes. |
258 * This is here only for debugging purposes. |
259 */ |
259 */ |
260 function _check($from_lines, $to_lines) |
260 function _check($from_lines, $to_lines) |
261 { |
261 { |
262 if (serialize($from_lines) != serialize($this->getOriginal())) { |
262 if (serialize($from_lines) != serialize($this->getOriginal())) { |
263 trigger_error("Reconstructed original does not match", E_USER_ERROR); |
263 throw new Text_Exception("Reconstructed original does not match"); |
264 } |
264 } |
265 if (serialize($to_lines) != serialize($this->getFinal())) { |
265 if (serialize($to_lines) != serialize($this->getFinal())) { |
266 trigger_error("Reconstructed final does not match", E_USER_ERROR); |
266 throw new Text_Exception("Reconstructed final does not match"); |
267 } |
267 } |
268 |
268 |
269 $rev = $this->reverse(); |
269 $rev = $this->reverse(); |
270 if (serialize($to_lines) != serialize($rev->getOriginal())) { |
270 if (serialize($to_lines) != serialize($rev->getOriginal())) { |
271 trigger_error("Reversed original does not match", E_USER_ERROR); |
271 throw new Text_Exception("Reversed original does not match"); |
272 } |
272 } |
273 if (serialize($from_lines) != serialize($rev->getFinal())) { |
273 if (serialize($from_lines) != serialize($rev->getFinal())) { |
274 trigger_error("Reversed final does not match", E_USER_ERROR); |
274 throw new Text_Exception("Reversed final does not match"); |
275 } |
275 } |
276 |
276 |
277 $prevtype = null; |
277 $prevtype = null; |
278 foreach ($this->_edits as $edit) { |
278 foreach ($this->_edits as $edit) { |
279 if ($edit instanceof $prevtype) { |
279 if ($prevtype !== null && $edit instanceof $prevtype) { |
280 trigger_error("Edit sequence is non-optimal", E_USER_ERROR); |
280 throw new Text_Exception("Edit sequence is non-optimal"); |
281 } |
281 } |
282 $prevtype = get_class($edit); |
282 $prevtype = get_class($edit); |
283 } |
283 } |
284 |
284 |
285 return true; |
285 return true; |