Skip to content

Commit

Permalink
fix: properly handle removed items in diff
Browse files Browse the repository at this point in the history
  • Loading branch information
smhg committed May 6, 2014
1 parent 386723b commit 8b95b68
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Timespan/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ public function diff(Collection $collection)
$diff = $tmp[$i]->diff($collection[$j])->getArrayCopy();

if (empty($diff)) {
// remove left item, proceed to next
array_splice($tmp, $i, 1);
$i--;
$resultLength--;
break;
} else {
// replace item with first item from diff
// replace left item with first item from diff
array_splice($tmp, $i, 1, array_splice($diff, 0, 1));
if (!empty($diff)) {
// if diff has second item, insert at right location
Expand Down

0 comments on commit 8b95b68

Please sign in to comment.