Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Laravel 5.3.28 changes (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
besologic authored Dec 15, 2016
1 parent 726d0cf commit bb49526
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ public function max($callback = null)
{
$callback = $this->valueRetriever($callback);

return $this->filter()->reduce(function ($result, $item) use ($callback) {
return $this->filter(function ($value) {
return ! is_null($value);
})->reduce(function ($result, $item) use ($callback) {
$value = $callback($item);

return is_null($result) || $value > $result ? $value : $result;
Expand Down Expand Up @@ -699,7 +701,9 @@ public function min($callback = null)
{
$callback = $this->valueRetriever($callback);

return $this->filter()->reduce(function ($result, $item) use ($callback) {
return $this->filter(function ($value) {
return ! is_null($value);
})->reduce(function ($result, $item) use ($callback) {
$value = $callback($item);

return is_null($result) || $value < $result ? $value : $result;
Expand Down
3 changes: 3 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,9 @@ public function testGettingMinItemsFromCollection()
$c = new Collection([1, null, 3, 4, 5]);
$this->assertEquals(1, $c->min());

$c = new Collection([0, 1, 2, 3, 4]);
$this->assertEquals(0, $c->min());

$c = new Collection();
$this->assertNull($c->min());
}
Expand Down

0 comments on commit bb49526

Please sign in to comment.