Skip to content

Commit

Permalink
refactor(paginator): optimize collection usage in getUrlRange method …
Browse files Browse the repository at this point in the history
…(#7209)
  • Loading branch information
huangdijia authored Dec 17, 2024
1 parent b637a3d commit dd9d59f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/AbstractPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
use Hyperf\Support\Traits\ForwardsCalls;
use Stringable;

use function Hyperf\Collection\collect;

abstract class AbstractPaginator implements PaginatorInterface, ArrayAccess, Stringable
{
use ForwardsCalls;
Expand Down Expand Up @@ -120,9 +118,9 @@ public function previousPageUrl(): ?string
*/
public function getUrlRange(int $start, int $end): array
{
return collect(range($start, $end))->mapWithKeys(function ($page) {
return [$page => $this->url($page)];
})->all();
return Collection::range($start, $end)
->mapWithKeys(fn ($page) => [$page => $this->url($page)])
->all();
}

/**
Expand Down

0 comments on commit dd9d59f

Please sign in to comment.