Initial Version

This commit is contained in:
root
2025-12-21 10:09:54 -05:00
commit 4ae6befc7b
422 changed files with 47225 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Sort;
interface ISort {
/**
* List of available attributes
*
* @since 1.0.0
*
* @return array<string,bool>
*/
public function attributes(): array;
/**
* Define sort condition
*
* @since 1.0.0
*
* @param string $attribute attribute name
* @param bool $direction true for ascending, false for descending
*/
public function condition(string $property, bool $direction): void;
/**
* List of sort conditions
*
* @since 1.0.0
*
* @return array<string,array{attribute:string,direction:bool}>
*/
public function conditions(): array;
}

View File

@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* 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<string,bool>
*/
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<string,array{attribute:string, direction:bool}>
*/
public function conditions(): array {
return $this->conditions;
}
}