예제 #1
0
 public function testFirstAndLast()
 {
     $collection = new Collection([1, 2, 3]);
     $this->assertSame(1, $collection->first());
     $this->assertSame(3, $collection->last());
 }
예제 #2
0
<?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);
예제 #3
0
<?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());