Skip to content

Commit

Permalink
Added fill method
Browse files Browse the repository at this point in the history
  • Loading branch information
maxalmonte14 committed Nov 18, 2018
1 parent d2f9483 commit a42b2ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/PHPCollections-Collections-BaseCollection.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ Determines if two collections are equal.
#### Arguments
* $collection **\PHPCollections\Collections\BaseCollection**

### fill

void PHPCollections\Collections\BaseCollection::fill()

Fills the collection with data.

* Visibility: **public**

### first

mixed PHPCollections\Collections\BaseCollection::first()
Expand Down
16 changes: 15 additions & 1 deletion src/Collections/BaseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,24 @@ public function exists($offset): bool
*
* @param \PHPCollections\Collections\BaseCollection $collection
*
* @return \PHPCollections\Collections\BaseCollection
* @return bool
*/
abstract public function equals(self $collection): bool;

/**
* Fills the collection with data.
*
* @param array $data
*
* @return void
*/
public function fill(array $data): void
{
foreach ($data as $entry) {
$this->add($entry);
}
}

/**
* Gets the first element in the collection.
*
Expand Down

0 comments on commit a42b2ad

Please sign in to comment.