* SPDX-License-Identifier: AGPL-3.0-or-later */ namespace KTXF\Resource\Sort; class Sort implements ISort { protected array $attributes = []; protected array $conditions = []; public function __construct(array $attributes) { $this->attributes = $attributes; } /** * * @since 1.0.0 * * @return array */ public function attributes(): array { return $this->attributes; } /** * * @since 1.0.0 * * @param string $attribute attribute name * @param bool $direction true for ascending, false for descending */ public function condition(string $attribute, bool $direction): void { if (isset($this->attributes[$attribute])) { $this->conditions[$attribute] = [ 'attribute' => $attribute, 'direction' => $direction, ]; } } /** * * @since 1.0.0 * * @return array */ public function conditions(): array { return $this->conditions; } }