first() публичный Метод

Get the first item from the collection.
public first ( Closure $callback = null, mixed $default = null ) : mixed | null
$callback Closure
$default mixed
Результат mixed | null
Пример #1
0
 public function testFirstWithCallbackAndDefault()
 {
     $data = new Collection(array('foo', 'bar'));
     $result = $data->first(function ($key, $value) {
         return $value === 'baz';
     }, 'default');
     $this->assertEquals('default', $result);
 }