*/ protected array $parts = []; public function __construct( string|null $sort = null, string|null $order = null, ) { if ($sort) { $this->add($sort, $order); } } public function add(string $sort, string|null $order = null): void { $order = ! $order ? 'ASC' : $order; $this->parts[] = $sort . ' ' . $order; } /** @psalm-return 0|positive-int */ public function count(): int { return count($this->parts); } /** @psalm-return list */ public function getParts(): array { return $this->parts; } public function __toString(): string { return $this->preSeparator . implode($this->separator, $this->parts) . $this->postSeparator; } }