Skip to content

Commit

Permalink
rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 2, 2021
1 parent b72178d commit 5b7ffc2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@ public function isEmpty()
}

/**
* Determine if the collection contains a single element.
* Determine if the collection contains a single item.
*
* @return bool
*/
public function isSingle()
public function containsOneItem()
{
return $this->count() === 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,11 @@ public function isEmpty()
}

/**
* Determine if the collection contains a single element.
* Determine if the collection contains a single item.
*
* @return bool
*/
public function isSingle()
public function containsOneItem()
{
return $this->take(2)->count() === 1;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,11 @@ public function testCountableByWithCallback($collection)
/**
* @dataProvider collectionClassProvider
*/
public function testIsSingle($collection)
public function testContainsOneItem($collection)
{
$this->assertFalse((new $collection([]))->isSingle());
$this->assertTrue((new $collection([1]))->isSingle());
$this->assertFalse((new $collection([1, 2]))->isSingle());
$this->assertFalse((new $collection([]))->containsOneItem());
$this->assertTrue((new $collection([1]))->containsOneItem());
$this->assertFalse((new $collection([1, 2]))->containsOneItem());
}

public function testIterable()
Expand Down
4 changes: 2 additions & 2 deletions tests/Support/SupportLazyCollectionIsLazyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,10 @@ public function testIsNotEmptyIsLazy()
});
}

public function testIsSingleIsLazy()
public function testContainsOneItemIsLazy()
{
$this->assertEnumerates(2, function ($collection) {
$collection->isSingle();
$collection->containsOneItem();
});
}

Expand Down

0 comments on commit 5b7ffc2

Please sign in to comment.