19 declare(strict_types=1);
33 private readonly
string $key;
38 $parts = explode(
'_', $sort_by);
40 $direction =
$parts[1] ??
'';
43 'title' => [
'badge',
'getTitle',
'strcasecmp'],
44 'date' => [
'assignment',
'getTimestamp', $this->
minus()],
46 $directions = [
'asc' =>
'asc',
'desc' =>
'desc'];
48 $key = isset($map[$what]) ? $what :
key($map);
51 $this->badgeOrAssignment = $map[
$key][0];
52 $this->method = $map[
$key][1];
53 $this->
compare = Closure::fromCallable($map[$key][2]);
63 public function compare(array $badge_and_assignment, array $other):
int 72 public function key(): string
88 'title_asc' =>
'sort_by_title_asc',
89 'title_desc' =>
'sort_by_title_desc',
90 'date_asc' =>
'sort_by_date_asc',
91 'date_desc' =>
'sort_by_date_desc',
97 return $this->direction ===
'asc' ? 1 : -1;
102 return static fn(
int $x,
int $y):
int => $x - $y;
readonly Closure $compare
__construct(string $sort_by='')
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
readonly string $direction
readonly string $badgeOrAssignment
compare(array $badge_and_assignment, array $other)