Skip to content

Commit

Permalink
Merge pull request #486 from lartisan/main
Browse files Browse the repository at this point in the history
Add last() method on DataCollection
  • Loading branch information
rubenvanassche committed Jul 5, 2023
2 parents c89bb58 + f49f784 commit d5cdc09
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Concerns/EnumerableMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ public function first(callable|null $callback = null, $default = null)
return $this->items->first($callback, $default);
}

/**
* @template TLastDefault
*
* @param null| (callable(TValue,TKey): bool) $callback
* @param TLastDefault|(\Closure(): TLastDefault) $default
*
* @return TValue|TLastDefault
*/
public function last(callable|null $callback = null, $default = null)
{
return $this->items->last($callback, $default);
}

/**
* @param callable(TValue, TKey): mixed $callback
*
Expand Down

0 comments on commit d5cdc09

Please sign in to comment.