Skip to content

Commit

Permalink
Slice, Sort, and Map return Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
valzargaming committed Jan 16, 2025
1 parent 9b2e0fc commit 8160c66
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Discord/Helpers/CollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function slice(int $offset, ?int $length, bool $preserve_keys = false)

$items = array_slice($items, $offset, $length, $preserve_keys);

return new static($items, $this->discrim, $this->class);
return new Collection($items, $this->discrim, $this->class);
}

/**
Expand All @@ -328,7 +328,7 @@ public function sort(callable|int|null $callback)
? uasort($items, $callback)
: asort($items, $callback ?? SORT_REGULAR);

return new static($items, $this->discrim, $this->class);
return new Collection($items, $this->discrim, $this->class);
}

/**
Expand All @@ -343,7 +343,7 @@ public function map(callable $callback)
$keys = array_keys($this->items);
$values = array_map($callback, array_values($this->items));

return new static(array_combine($keys, $values), $this->discrim, $this->class);
return new Collection(array_combine($keys, $values), $this->discrim, $this->class);
}

/**
Expand Down

0 comments on commit 8160c66

Please sign in to comment.