Skip to content

Commit

Permalink
collect()
Browse files Browse the repository at this point in the history
  • Loading branch information
valzargaming committed Jan 17, 2025
1 parent 0a271bc commit 7e69786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Discord/Helpers/CollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function reduce(callable $callback, $initial = null);
public function map(callable $callback);
public function merge($collection): self;
public function toArray();
public function collect();
public function keys(): array;
public function values(): array;
public function diff(): array;
Expand Down
10 changes: 10 additions & 0 deletions src/Discord/Helpers/CollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ public function toArray()
return $this->items;
}

/**
* Converts the items into a new collection.
*
* @return CollectionInterface
*/
public function collect()
{
return new Collection($this->items, $this->discrim, $this->class);
}

/**
* @since 11.0.0
*
Expand Down

0 comments on commit 7e69786

Please sign in to comment.