Skip to content

Commit

Permalink
shift()
Browse files Browse the repository at this point in the history
  • Loading branch information
valzargaming committed Jan 17, 2025
1 parent cb2e7a3 commit 7893f56
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Discord/Helpers/CollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ public function pull($key, $default = null)
return $default;
}

/**
* Shifts an item from the collection.
*
* @return mixed
*/
public function shift()
{
if (empty($this->items)) {
return null;
}

reset($this->items);
$key = key($this->items);
$value = array_shift($this->items);

return [$key => $value];
}

/**
* Fills an array of items into the collection.
*
Expand Down

0 comments on commit 7893f56

Please sign in to comment.