public function testFirstAndLast() { $collection = new Collection([1, 2, 3]); $this->assertSame(1, $collection->first()); $this->assertSame(3, $collection->last()); }
<?php namespace Rubicon\Collection; use Rubicon\Collection\Constraint\IsEqualTo; require dirname(__DIR__) . '/vendor/autoload.php'; $collection = new Collection([1, 2, 3]); $sliced = $collection->reject(new IsEqualTo(1)); print_r($sliced);
<?php namespace Rubicon\Collection; use Rubicon\Collection\Constraint\ZendValidator; use Zend\Validator\EmailAddress; require dirname(__DIR__) . '/vendor/autoload.php'; $constraint = new ZendValidator(new EmailAddress()); $collection = new Collection(['*****@*****.**', 'hello world', '*****@*****.**']); $result = $collection->filter($constraint); print_r($result->get());