Exemplo n.º 1
0
 function test_first()
 {
     $data = array('dev1' => 'Tonya', 'dev2' => 'Julie');
     $this->assertEquals('Julie', Arr::first($data, function ($key, $value) {
         return $value == 'Julie';
     }));
     $this->assertEquals('Julie', wpdevsclub_array_first($data, function ($key, $value) {
         return $value == 'Julie';
     }));
 }
Exemplo n.º 2
0
 /**
  * Get the first item from the collection.
  *
  * @param  \Closure   $callback
  * @param  mixed      $default
  * @return mixed|null
  */
 public function first(Closure $callback = null, $default = null)
 {
     if (is_null($callback)) {
         return count($this->items) > 0 ? reset($this->items) : null;
     }
     return wpdevsclub_array_first($this->items, $callback, $default);
 }