Skip to content
Permalink
Browse files

Implemented Collection::skip()

  • Loading branch information...
lorenzo committed May 16, 2015
1 parent 5cf8c01 commit 8c10deec570132ec51fad393979824c711418943
@@ -482,6 +482,15 @@ public function sample($size = 10);
*/
public function take($size = 1, $from = 0);
/**
* Returns a new collection that will the specified amount of elements.
* at the beginning of the iteration.
*
* @param int $howMany The number of elements to skip.
* @return \Cake\Collection\CollectionInterface
*/
public function skip($howMany);
/**
* Looks through each value in the list, returning a Collection of all the
* values that contain all of the key-value pairs listed in $conditions.
@@ -282,6 +282,14 @@ public function take($size = 1, $from = 0)
return new Collection(new LimitIterator($this->unwrap(), $from, $size));
}
/**
* {@inheritDoc}
*
*/
public function skip($howMany) {
return new Collection(new LimitIterator($this->unwrap(), $howMany));
}
/**
* {@inheritDoc}
*
@@ -1327,4 +1327,17 @@ public function testZipWith()
});
$this->assertEquals([9, 12], $zipped->toList());
}
/**
* Tests the skip() method
*
* @return void
*/
public function testSkip()
{
$collection = new Collection([1, 2, 3, 4, 5]);
$this->assertEquals([3, 4, 5], $collection->skip(2)->toList());
$this->assertEquals([5], $collection->skip(4)->toList());
}
}

0 comments on commit 8c10dee

Please sign in to comment.
You can’t perform that action at this time.