Skip to content

Commit

Permalink
Add isNotEmpty() method to Collection class (#16797)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerguslejko authored and taylorotwell committed Dec 14, 2016
1 parent 5859b21 commit 2ee552d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ public function isEmpty()
return empty($this->items);
}

/**
* Determine if the collection is not empty.
*
* @return bool
*/
public function isNotEmpty()
{
return ! $this->isEmpty();
}

/**
* Determine if the given value is callable, but not a string.
*
Expand Down
8 changes: 8 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ public function testEmptyCollectionIsEmpty()
$this->assertTrue($c->isEmpty());
}

public function testEmptyCollectionIsNotEmpty()
{
$c = new Collection(['foo', 'bar']);

$this->assertFalse($c->isEmpty());
$this->assertTrue($c->isNotEmpty());
}

public function testCollectionIsConstructed()
{
$collection = new Collection('foo');
Expand Down

0 comments on commit 2ee552d

Please sign in to comment.