mirror of
https://github.com/shlinkio/shlink.git
synced 2026-09-03 19:52:51 -05:00
41 lines
760 B
PHP
41 lines
760 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\Core\Model;
|
|
|
|
final class Ordering
|
|
{
|
|
private const DEFAULT_DIR = 'ASC';
|
|
|
|
private function __construct(private ?string $field, private string $dir)
|
|
{
|
|
}
|
|
|
|
public static function fromTuple(array $props): self
|
|
{
|
|
[$field, $dir] = $props;
|
|
return new self($field, $dir ?? self::DEFAULT_DIR);
|
|
}
|
|
|
|
public static function emptyInstance(): self
|
|
{
|
|
return self::fromTuple([null, null]);
|
|
}
|
|
|
|
public function orderField(): ?string
|
|
{
|
|
return $this->field;
|
|
}
|
|
|
|
public function orderDirection(): string
|
|
{
|
|
return $this->dir;
|
|
}
|
|
|
|
public function hasOrderField(): bool
|
|
{
|
|
return $this->field !== null;
|
|
}
|
|
}
|