Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7197eaebf2
commit
9c0f8de791
15771 changed files with 1564103 additions and 5 deletions
85
vendor/league/csv/src/Query/Constraint/Column.php
vendored
Normal file
85
vendor/league/csv/src/Query/Constraint/Column.php
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query\Constraint;
|
||||
|
||||
use CallbackFilterIterator;
|
||||
use Closure;
|
||||
use Iterator;
|
||||
use League\Csv\MapIterator;
|
||||
use League\Csv\Query;
|
||||
use ReflectionException;
|
||||
|
||||
/**
|
||||
* Enable filtering a record based on the value of a one of its cell.
|
||||
*
|
||||
* When used with PHP's array_filter with the ARRAY_FILTER_USE_BOTH flag
|
||||
* the record offset WILL NOT BE taken into account
|
||||
*/
|
||||
final class Column implements Query\Predicate
|
||||
{
|
||||
/**
|
||||
* @throws Query\QueryException
|
||||
*/
|
||||
private function __construct(
|
||||
public readonly string|int $column,
|
||||
public readonly Comparison|Closure $operator,
|
||||
public readonly mixed $value,
|
||||
) {
|
||||
if (!$this->operator instanceof Closure) {
|
||||
$this->operator->accept($this->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Query\QueryException
|
||||
*/
|
||||
public static function filterOn(
|
||||
string|int $column,
|
||||
Comparison|Closure|callable|string $operator,
|
||||
mixed $value = null,
|
||||
): self {
|
||||
if ($operator instanceof Closure) {
|
||||
return new self($column, $operator, null);
|
||||
}
|
||||
|
||||
if (is_callable($operator)) {
|
||||
return new self($column, $operator(...), $value);
|
||||
}
|
||||
|
||||
return new self(
|
||||
$column,
|
||||
is_string($operator) ? Comparison::fromOperator($operator) : $operator,
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
* @throws Query\QueryException
|
||||
*/
|
||||
public function __invoke(mixed $value, int|string $key): bool
|
||||
{
|
||||
$subject = Query\Row::from($value)->value($this->column);
|
||||
if ($this->operator instanceof Closure) {
|
||||
return ($this->operator)($subject);
|
||||
}
|
||||
|
||||
return $this->operator->compare($subject, $this->value);
|
||||
}
|
||||
|
||||
public function filter(iterable $value): Iterator
|
||||
{
|
||||
return new CallbackFilterIterator(MapIterator::toIterator($value), $this);
|
||||
}
|
||||
}
|
||||
157
vendor/league/csv/src/Query/Constraint/Comparison.php
vendored
Normal file
157
vendor/league/csv/src/Query/Constraint/Comparison.php
vendored
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query\Constraint;
|
||||
|
||||
use League\Csv\Query\QueryException;
|
||||
|
||||
use function array_is_list;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function str_contains;
|
||||
use function str_ends_with;
|
||||
use function str_starts_with;
|
||||
use function strtoupper;
|
||||
use function trim;
|
||||
|
||||
enum Comparison: string
|
||||
{
|
||||
case Equals = '=';
|
||||
case NotEquals = '!=';
|
||||
case GreaterThan = '>';
|
||||
case GreaterThanOrEqual = '>=';
|
||||
case LesserThan = '<';
|
||||
case LesserThanOrEqual = '<=';
|
||||
case Between = 'BETWEEN';
|
||||
case NotBetween = 'NBETWEEN';
|
||||
case Regexp = 'REGEXP';
|
||||
case NotRegexp = 'NREGEXP';
|
||||
case In = 'IN';
|
||||
case NotIn = 'NIN';
|
||||
case Contains = 'CONTAINS';
|
||||
case NotContain = 'NCONTAIN';
|
||||
case StartsWith = 'STARTS_WITH';
|
||||
case EndsWith = 'ENDS_WITH';
|
||||
|
||||
public static function tryFromOperator(string $operator): ?self
|
||||
{
|
||||
$operator = strtoupper(trim($operator));
|
||||
|
||||
return match ($operator) {
|
||||
'<>', 'NEQ', 'IS NOT', 'NOT EQUAL' => self::NotEquals,
|
||||
'EQ', 'IS', 'EQUAL', 'EQUALS' => self::Equals,
|
||||
'GT', 'GREATER THAN' => self::GreaterThan,
|
||||
'GTE', 'GREATER THAN OR EQUAL' => self::GreaterThanOrEqual,
|
||||
'LT', 'LESSER THAN' => self::LesserThan,
|
||||
'LTE', 'LESSER THAN OR EQUAL' => self::LesserThanOrEqual,
|
||||
'NOT_REGEXP', 'NOT REGEXP' => self::NotRegexp,
|
||||
'NOT_CONTAIN', 'NOT CONTAIN', 'DOES_NOT_CONTAIN', 'DOES NOT CONTAIN' => self::NotContain,
|
||||
'NOT_IN', 'NOT IN' => self::NotIn,
|
||||
'NOT_BETWEEN', 'NOT BETWEEN' => self::Between,
|
||||
'STARTS WITH', 'START WITH' => self::StartsWith,
|
||||
'ENDS WITH', 'END WITH' => self::EndsWith,
|
||||
default => self::tryFrom($operator),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws QueryException
|
||||
*/
|
||||
public static function fromOperator(string $operator): self
|
||||
{
|
||||
return self::tryFromOperator($operator) ?? throw QueryException::dueToUnknownOperator($operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Values comparison.
|
||||
*
|
||||
* The method return true if the values satisfy the comparison operator, otherwise false is returned.
|
||||
*
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function compare(mixed $subject, mixed $reference): bool
|
||||
{
|
||||
$this->accept($reference);
|
||||
|
||||
return match ($this) {
|
||||
self::Equals => self::isSingleValue($subject) ? $subject === $reference : $subject == $reference,
|
||||
self::NotEquals => self::isSingleValue($subject) ? $subject !== $reference : $subject != $reference,
|
||||
self::GreaterThan => $subject > $reference,
|
||||
self::GreaterThanOrEqual => $subject >= $reference,
|
||||
self::LesserThan => $subject < $reference,
|
||||
self::LesserThanOrEqual => $subject <= $reference,
|
||||
self::Between => $subject >= $reference[0] && $subject <= $reference[1], /* @phpstan-ignore-line */
|
||||
self::NotBetween => $subject < $reference[0] || $subject > $reference[1], /* @phpstan-ignore-line */
|
||||
self::In => in_array($subject, $reference, self::isSingleValue($subject)), /* @phpstan-ignore-line */
|
||||
self::NotIn => !in_array($subject, $reference, self::isSingleValue($subject)), /* @phpstan-ignore-line */
|
||||
self::Regexp => is_string($subject) && 1 === preg_match($reference, $subject), /* @phpstan-ignore-line */
|
||||
self::NotRegexp => is_string($subject) && 1 !== preg_match($reference, $subject), /* @phpstan-ignore-line */
|
||||
self::Contains => is_string($subject) && str_contains($subject, $reference), /* @phpstan-ignore-line */
|
||||
self::NotContain => is_string($subject) && !str_contains($subject, $reference), /* @phpstan-ignore-line */
|
||||
self::StartsWith => is_string($subject) && str_starts_with($subject, $reference), /* @phpstan-ignore-line */
|
||||
self::EndsWith => is_string($subject) && str_ends_with($subject, $reference), /* @phpstan-ignore-line */
|
||||
};
|
||||
}
|
||||
|
||||
private static function isSingleValue(mixed $value): bool
|
||||
{
|
||||
return is_scalar($value) || null === $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if the reference value can be used with the Enum operator.
|
||||
*
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function accept(mixed $reference): void
|
||||
{
|
||||
match ($this) {
|
||||
self::Between,
|
||||
self::NotBetween => match (true) {
|
||||
!is_array($reference),
|
||||
!array_is_list($reference),
|
||||
2 !== count($reference) => throw new QueryException('The value used for comparison with the `'.$this->name.'` operator must be an list containing 2 values, the minimum and maximum values.'),
|
||||
default => true,
|
||||
},
|
||||
self::In,
|
||||
self::NotIn => match (true) {
|
||||
!is_array($reference) => throw new QueryException('The value used for comparison with the `'.$this->name.'` operator must be an array.'),
|
||||
default => true,
|
||||
},
|
||||
self::Regexp,
|
||||
self::NotRegexp => match (true) {
|
||||
!is_string($reference),
|
||||
'' === $reference,
|
||||
false === @preg_match($reference, '') => throw new QueryException('The value used for comparison with the `'.$this->name.'` operator must be a valid regular expression pattern string.'),
|
||||
default => true,
|
||||
},
|
||||
self::Contains,
|
||||
self::NotContain,
|
||||
self::StartsWith,
|
||||
self::EndsWith => match (true) {
|
||||
!is_string($reference),
|
||||
'' === $reference => throw new QueryException('The value used for comparison with the `'.$this->name.'` operator must be a non empty string.'),
|
||||
default => true,
|
||||
},
|
||||
self::Equals,
|
||||
self::NotEquals,
|
||||
self::GreaterThanOrEqual,
|
||||
self::GreaterThan,
|
||||
self::LesserThanOrEqual,
|
||||
self::LesserThan => true,
|
||||
};
|
||||
}
|
||||
}
|
||||
168
vendor/league/csv/src/Query/Constraint/Criteria.php
vendored
Normal file
168
vendor/league/csv/src/Query/Constraint/Criteria.php
vendored
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query\Constraint;
|
||||
|
||||
use CallbackFilterIterator;
|
||||
use Closure;
|
||||
use Iterator;
|
||||
use League\Csv\MapIterator;
|
||||
use League\Csv\Query\Predicate;
|
||||
use League\Csv\Query\PredicateCombinator;
|
||||
|
||||
use function array_reduce;
|
||||
|
||||
/**
|
||||
* @phpstan-import-type Condition from PredicateCombinator
|
||||
* @phpstan-import-type ConditionExtended from PredicateCombinator
|
||||
*/
|
||||
final class Criteria implements PredicateCombinator
|
||||
{
|
||||
/**
|
||||
* @param Condition $predicate
|
||||
*/
|
||||
private function __construct(private readonly Predicate|Closure $predicate)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with predicates join using the logical AND operator.
|
||||
*
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public static function all(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return new self(function (mixed $value, int|string $key) use ($predicates): bool {
|
||||
foreach ($predicates as $predicate) {
|
||||
if (!$predicate($value, $key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with predicates join using the logical NOT operator.
|
||||
*
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public static function none(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return new self(function (mixed $value, int|string $key) use ($predicates): bool {
|
||||
foreach ($predicates as $predicate) {
|
||||
if ($predicate($value, $key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with predicates join using the logical OR operator.
|
||||
*
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public static function any(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return new self(function (mixed $value, int|string $key) use ($predicates): bool {
|
||||
foreach ($predicates as $predicate) {
|
||||
if ($predicate($value, $key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with predicates join using the logical XOR operator.
|
||||
*
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public static function xany(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return new self(fn (mixed $value, int|string $key): bool => array_reduce(
|
||||
$predicates,
|
||||
fn (bool $bool, Predicate|Closure|callable $predicate) => $predicate($value, $key) xor $bool,
|
||||
false
|
||||
));
|
||||
}
|
||||
|
||||
public function __invoke(mixed $value, int|string $key): bool
|
||||
{
|
||||
return ($this->predicate)($value, $key);
|
||||
}
|
||||
|
||||
public function filter(iterable $value): Iterator
|
||||
{
|
||||
return new CallbackFilterIterator(MapIterator::toIterator($value), $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public function and(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return self::all($this->predicate, ...$predicates);
|
||||
}
|
||||
|
||||
public function andNot(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return self::all($this->predicate, self::none(...$predicates));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public function not(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return self::none($this->predicate, ...$predicates);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public function or(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return self::any($this->predicate, ...$predicates);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public function orNot(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return self::any($this->predicate, self::none(...$predicates));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public function xor(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return self::xany($this->predicate, ...$predicates);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConditionExtended ...$predicates
|
||||
*/
|
||||
public function xorNot(Predicate|Closure|callable ...$predicates): self
|
||||
{
|
||||
return self::xany($this->predicate, self::none(...$predicates));
|
||||
}
|
||||
}
|
||||
79
vendor/league/csv/src/Query/Constraint/Offset.php
vendored
Normal file
79
vendor/league/csv/src/Query/Constraint/Offset.php
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query\Constraint;
|
||||
|
||||
use CallbackFilterIterator;
|
||||
use Closure;
|
||||
use Iterator;
|
||||
use League\Csv\MapIterator;
|
||||
use League\Csv\Query;
|
||||
|
||||
/**
|
||||
* Enable filtering a record based on its offset.
|
||||
*
|
||||
* When used with PHP's array_filter with the ARRAY_FILTER_USE_BOTH flag
|
||||
* the record value WILL NOT BE taken into account
|
||||
*/
|
||||
final class Offset implements Query\Predicate
|
||||
{
|
||||
/**
|
||||
* @throws Query\QueryException
|
||||
*/
|
||||
private function __construct(
|
||||
public readonly Comparison|Closure $operator,
|
||||
public readonly mixed $value,
|
||||
) {
|
||||
if (!$this->operator instanceof Closure) {
|
||||
$this->operator->accept($this->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Query\QueryException
|
||||
*/
|
||||
public static function filterOn(
|
||||
Comparison|Closure|callable|string $operator,
|
||||
mixed $value = null,
|
||||
): self {
|
||||
if ($operator instanceof Closure) {
|
||||
return new self($operator, null);
|
||||
}
|
||||
|
||||
if (is_callable($operator)) {
|
||||
return new self(Closure::fromCallable($operator), $value);
|
||||
}
|
||||
|
||||
return new self(
|
||||
is_string($operator) ? Comparison::fromOperator($operator) : $operator,
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Query\QueryException
|
||||
*/
|
||||
public function __invoke(mixed $value, int|string $key): bool
|
||||
{
|
||||
if ($this->operator instanceof Closure) {
|
||||
return ($this->operator)($key);
|
||||
}
|
||||
|
||||
return $this->operator->compare($key, $this->value);
|
||||
}
|
||||
|
||||
public function filter(iterable $value): Iterator
|
||||
{
|
||||
return new CallbackFilterIterator(MapIterator::toIterator($value), $this);
|
||||
}
|
||||
}
|
||||
99
vendor/league/csv/src/Query/Constraint/TwoColumns.php
vendored
Normal file
99
vendor/league/csv/src/Query/Constraint/TwoColumns.php
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query\Constraint;
|
||||
|
||||
use CallbackFilterIterator;
|
||||
use Closure;
|
||||
use Iterator;
|
||||
use League\Csv\MapIterator;
|
||||
use League\Csv\Query\Predicate;
|
||||
use League\Csv\Query\QueryException;
|
||||
use League\Csv\Query\Row;
|
||||
use ReflectionException;
|
||||
|
||||
use function array_filter;
|
||||
use function is_array;
|
||||
use function is_int;
|
||||
use function is_string;
|
||||
|
||||
use const ARRAY_FILTER_USE_BOTH;
|
||||
|
||||
/**
|
||||
* Enable filtering a record by comparing the values of two of its column.
|
||||
*
|
||||
* When used with PHP's array_filter with the ARRAY_FILTER_USE_BOTH flag
|
||||
* the record offset WILL NOT BE taken into account
|
||||
*/
|
||||
final class TwoColumns implements Predicate
|
||||
{
|
||||
/**
|
||||
* @throws QueryException
|
||||
*/
|
||||
private function __construct(
|
||||
public readonly string|int $first,
|
||||
public readonly Comparison|Closure $operator,
|
||||
public readonly array|string|int $second,
|
||||
) {
|
||||
!$this->operator instanceof Closure || !is_array($this->second) || throw new QueryException('The second column must be a string if the operator is a callback.');
|
||||
|
||||
if (is_array($this->second)) {
|
||||
$res = array_filter($this->second, fn (mixed $value): bool => !is_string($value) && !is_int($value));
|
||||
if ([] !== $res) {
|
||||
throw new QueryException('The second column must be a string, an integer or a list of strings and/or integer when the operator is not a callback.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws QueryException
|
||||
*/
|
||||
public static function filterOn(
|
||||
string|int $firstColumn,
|
||||
Comparison|Closure|callable|string $operator,
|
||||
array|string|int $secondColumn
|
||||
): self {
|
||||
if (is_string($operator)) {
|
||||
$operator = Comparison::fromOperator($operator);
|
||||
}
|
||||
|
||||
if (is_callable($operator)) {
|
||||
return new self($firstColumn, Closure::fromCallable($operator), $secondColumn);
|
||||
}
|
||||
|
||||
return new self($firstColumn, $operator, $secondColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws QueryException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function __invoke(mixed $value, int|string $key): bool
|
||||
{
|
||||
$val = match (true) {
|
||||
is_array($this->second) => array_values(Row::from($value)->select(...$this->second)),
|
||||
default => Row::from($value)->value($this->second),
|
||||
};
|
||||
|
||||
if ($this->operator instanceof Closure) {
|
||||
return ($this->operator)(Row::from($value)->value($this->first), $val);
|
||||
}
|
||||
|
||||
return Column::filterOn($this->first, $this->operator, $val)($value, $key);
|
||||
}
|
||||
|
||||
public function filter(iterable $value): Iterator
|
||||
{
|
||||
return new CallbackFilterIterator(MapIterator::toIterator($value), $this);
|
||||
}
|
||||
}
|
||||
50
vendor/league/csv/src/Query/Limit.php
vendored
Normal file
50
vendor/league/csv/src/Query/Limit.php
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query;
|
||||
|
||||
use Deprecated;
|
||||
use League\Csv\MapIterator;
|
||||
use LimitIterator;
|
||||
|
||||
final class Limit
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $offset,
|
||||
public readonly int $length,
|
||||
) {
|
||||
0 <= $this->offset || throw new QueryException(self::class.' expects the offset to be greater or equal to 0, '.$this->offset.' given.');
|
||||
-2 < $this->length || throw new QueryException(self::class.' expects the length to be greater or equal to -1, '.$this->length.' given.');
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATION WARNING! This method will be removed in the next major point release.
|
||||
*
|
||||
* @see Limit::__construct()
|
||||
* @deprecated Since version 9.25.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
#[Deprecated(message:'use League\Csv\JsonConverter::__construct() instead', since:'league/csv:9.25.0')]
|
||||
public static function new(int $offset, int $length): self
|
||||
{
|
||||
return new self($offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows iteration over a limited subset of items in an iterable structure.
|
||||
*/
|
||||
public function slice(iterable $value): LimitIterator
|
||||
{
|
||||
return new LimitIterator(MapIterator::toIterator($value), $this->offset, $this->length);
|
||||
}
|
||||
}
|
||||
113
vendor/league/csv/src/Query/Ordering/Column.php
vendored
Normal file
113
vendor/league/csv/src/Query/Ordering/Column.php
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query\Ordering;
|
||||
|
||||
use ArrayIterator;
|
||||
use Closure;
|
||||
use Iterator;
|
||||
use League\Csv\Query\QueryException;
|
||||
use League\Csv\Query\Row;
|
||||
use League\Csv\Query\Sort;
|
||||
use OutOfBoundsException;
|
||||
use ReflectionException;
|
||||
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
use function iterator_to_array;
|
||||
use function strtoupper;
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
* Enable sorting a record based on the value of a one of its cell.
|
||||
*/
|
||||
final class Column implements Sort
|
||||
{
|
||||
private const ASCENDING = 'ASC';
|
||||
private const DESCENDING = 'DESC';
|
||||
|
||||
/**
|
||||
* @param Closure(mixed, mixed): int $callback
|
||||
*/
|
||||
private function __construct(
|
||||
public readonly string $direction,
|
||||
public readonly string|int $column,
|
||||
public readonly Closure $callback,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param (callable(mixed, mixed): int)|(Closure(mixed, mixed): int)|null $callback
|
||||
*
|
||||
* @throws QueryException
|
||||
*/
|
||||
public static function sortOn(
|
||||
string|int $column,
|
||||
string|int $direction,
|
||||
Closure|callable|null $callback = null
|
||||
): self {
|
||||
|
||||
$operator = match (true) {
|
||||
SORT_ASC === $direction => self::ASCENDING,
|
||||
SORT_DESC === $direction => self::DESCENDING,
|
||||
is_string($direction) => match (strtoupper(trim($direction))) {
|
||||
'ASC', 'ASCENDING', 'UP' => self::ASCENDING,
|
||||
'DESC', 'DESCENDING', 'DOWN' => self::DESCENDING,
|
||||
default => throw new QueryException('Unknown or unsupported ordering operator value: '.$direction),
|
||||
},
|
||||
default => throw new QueryException('Unknown or unsupported ordering operator value: '.$direction),
|
||||
};
|
||||
|
||||
$callback = match (true) {
|
||||
null === $callback => static fn (mixed $first, mixed $second): int => $first <=> $second,
|
||||
$callback instanceof Closure => $callback,
|
||||
default => $callback(...),
|
||||
};
|
||||
|
||||
return new self($operator, $column, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function __invoke(mixed $valueA, mixed $valueB): int
|
||||
{
|
||||
$first = Row::from($valueA)->value($this->column);
|
||||
$second = Row::from($valueB)->value($this->column);
|
||||
|
||||
return match ($this->direction) {
|
||||
self::ASCENDING => ($this->callback)($first, $second),
|
||||
default => ($this->callback)($second, $first),
|
||||
};
|
||||
}
|
||||
|
||||
public function sort(iterable $value): Iterator
|
||||
{
|
||||
$class = new class () extends ArrayIterator {
|
||||
public function seek(int $offset): void
|
||||
{
|
||||
try {
|
||||
parent::seek($offset);
|
||||
} catch (OutOfBoundsException) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$it = new $class(!is_array($value) ? iterator_to_array($value) : $value);
|
||||
$it->uasort($this);
|
||||
|
||||
return $it;
|
||||
}
|
||||
}
|
||||
115
vendor/league/csv/src/Query/Ordering/MultiSort.php
vendored
Normal file
115
vendor/league/csv/src/Query/Ordering/MultiSort.php
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query\Ordering;
|
||||
|
||||
use ArrayIterator;
|
||||
use Closure;
|
||||
use Iterator;
|
||||
use League\Csv\MapIterator;
|
||||
use League\Csv\Query\Sort;
|
||||
use League\Csv\Query\SortCombinator;
|
||||
use OutOfBoundsException;
|
||||
|
||||
use function array_map;
|
||||
|
||||
/**
|
||||
* Enable sorting a record based on multiple column.
|
||||
*
|
||||
* The class can be used with PHP's usort and uasort functions.
|
||||
*
|
||||
* @phpstan-import-type Ordering from SortCombinator
|
||||
* @phpstan-import-type OrderingExtended from SortCombinator
|
||||
*/
|
||||
final class MultiSort implements SortCombinator
|
||||
{
|
||||
/** @var array<Ordering> */
|
||||
private readonly array $sorts;
|
||||
|
||||
/**
|
||||
* @param OrderingExtended ...$sorts
|
||||
*/
|
||||
private function __construct(Sort|Closure|callable ...$sorts)
|
||||
{
|
||||
$this->sorts = array_map(
|
||||
static fn (Sort|Closure|callable $sort): Sort|Closure => $sort instanceof Closure || $sort instanceof Sort ? $sort : $sort(...),
|
||||
$sorts
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderingExtended ...$sorts
|
||||
*/
|
||||
public static function all(Sort|Closure|callable ...$sorts): self
|
||||
{
|
||||
return new self(...$sorts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderingExtended ...$sorts
|
||||
*/
|
||||
public function append(Sort|Closure|callable ...$sorts): self
|
||||
{
|
||||
if ([] === $sorts) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
return new self(...$this->sorts, ...$sorts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderingExtended ...$sorts
|
||||
*/
|
||||
public function prepend(Sort|Closure|callable ...$sorts): self
|
||||
{
|
||||
if ([] === $sorts) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
return (new self(...$sorts))->append(...$this->sorts);
|
||||
}
|
||||
|
||||
public function __invoke(mixed $valueA, mixed $valueB): int
|
||||
{
|
||||
foreach ($this->sorts as $sort) {
|
||||
if (0 !== ($result = $sort($valueA, $valueB))) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return $result ?? 0;
|
||||
}
|
||||
|
||||
public function sort(iterable $value): Iterator
|
||||
{
|
||||
if ([] === $this->sorts) {
|
||||
return MapIterator::toIterator($value);
|
||||
}
|
||||
|
||||
$class = new class () extends ArrayIterator {
|
||||
public function seek(int $offset): void
|
||||
{
|
||||
try {
|
||||
parent::seek($offset);
|
||||
} catch (OutOfBoundsException) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$it = new $class(!is_array($value) ? iterator_to_array($value) : $value);
|
||||
$it->uasort($this);
|
||||
|
||||
return $it;
|
||||
}
|
||||
}
|
||||
43
vendor/league/csv/src/Query/Predicate.php
vendored
Normal file
43
vendor/league/csv/src/Query/Predicate.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query;
|
||||
|
||||
use Iterator;
|
||||
|
||||
/**
|
||||
* Enable filtering a record based on its value and/or its offset.
|
||||
*
|
||||
* The class can be used directly with PHP's
|
||||
* <ol>
|
||||
* <li>array_filter with the ARRAY_FILTER_USE_BOTH flag.</li>
|
||||
* <li>CallbackFilterIterator class.</li>
|
||||
* </ol>
|
||||
*/
|
||||
interface Predicate
|
||||
{
|
||||
/**
|
||||
* The class predicate method.
|
||||
*
|
||||
* Evaluates each element of an iterable structure based on its value and its offset.
|
||||
* The method must return true if the predicate is satisfied, false otherwise.
|
||||
*/
|
||||
public function __invoke(mixed $value, string|int $key): bool;
|
||||
|
||||
/**
|
||||
* Filters elements of an iterable structure using the class predicate method.
|
||||
*
|
||||
* @see Predicate::__invoke
|
||||
*/
|
||||
public function filter(iterable $value): Iterator;
|
||||
}
|
||||
71
vendor/league/csv/src/Query/PredicateCombinator.php
vendored
Normal file
71
vendor/league/csv/src/Query/PredicateCombinator.php
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query;
|
||||
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* @phpstan-type Condition Predicate|Closure(mixed, array-key): bool
|
||||
* @phpstan-type ConditionExtended Predicate|Closure(mixed, array-key): bool|callable(mixed, array-key): bool
|
||||
*/
|
||||
interface PredicateCombinator extends Predicate
|
||||
{
|
||||
/**
|
||||
* Return an instance with the specified predicates
|
||||
* joined together and with the current predicate
|
||||
* using the AND Logical operator.
|
||||
*
|
||||
* This method MUST retain the state of the current instance, and return
|
||||
* an instance that contains the specified changes.
|
||||
*
|
||||
* @param Condition ...$predicates
|
||||
*/
|
||||
public function and(Predicate|Closure ...$predicates): self;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified predicates
|
||||
* joined together and with the current predicate
|
||||
* using the OR Logical operator.
|
||||
*
|
||||
* This method MUST retain the state of the current instance, and return
|
||||
* an instance that contains the specified changes.
|
||||
*
|
||||
* @param Condition ...$predicates
|
||||
*/
|
||||
public function or(Predicate|Closure ...$predicates): self;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified predicates
|
||||
* joined together and with the current predicate
|
||||
* using the NOT Logical operator.
|
||||
*
|
||||
* This method MUST retain the state of the current instance, and return
|
||||
* an instance that contains the specified changes.
|
||||
*
|
||||
* @param Condition ...$predicates
|
||||
*/
|
||||
public function not(Predicate|Closure ...$predicates): self;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified predicates
|
||||
* joined together and with the current predicate
|
||||
* using the XOR Logical operator.
|
||||
*
|
||||
* This method MUST retain the state of the current instance, and return
|
||||
* an instance that contains the specified changes.
|
||||
*
|
||||
* @param Condition ...$predicates
|
||||
*/
|
||||
public function xor(Predicate|Closure ...$predicates): self;
|
||||
}
|
||||
44
vendor/league/csv/src/Query/QueryException.php
vendored
Normal file
44
vendor/league/csv/src/Query/QueryException.php
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query;
|
||||
|
||||
use Exception;
|
||||
use League\Csv\UnableToProcessCsv;
|
||||
|
||||
final class QueryException extends Exception implements UnableToProcessCsv
|
||||
{
|
||||
public static function dueToUnknownColumn(string|int $column, array|object $value): self
|
||||
{
|
||||
return match (true) {
|
||||
is_object($value) => match (is_int($column)) {
|
||||
true => new self('The object property name can not be the integer`'.$column.'`.'),
|
||||
default => new self('The object property name `'.$column.'` could not be retrieved from the object.'),
|
||||
},
|
||||
default => match (is_string($column)) {
|
||||
true => new self('The column `'.$column.'` does not exist in the input array.'),
|
||||
default => new self('The column with the offset `'.$column.'` does not exist in the input array.'),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public static function dueToMissingColumn(): self
|
||||
{
|
||||
return new self('No valid column were found with the given data.');
|
||||
}
|
||||
|
||||
public static function dueToUnknownOperator(string $operator): self
|
||||
{
|
||||
return new self('Unknown or unsupported comparison operator `'.$operator.'`');
|
||||
}
|
||||
}
|
||||
176
vendor/league/csv/src/Query/Row.php
vendored
Normal file
176
vendor/league/csv/src/Query/Row.php
vendored
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query;
|
||||
|
||||
use ArrayAccess;
|
||||
use ReflectionException;
|
||||
use ReflectionObject;
|
||||
use TypeError;
|
||||
|
||||
use function array_is_list;
|
||||
use function array_key_exists;
|
||||
use function array_map;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function explode;
|
||||
use function implode;
|
||||
use function is_array;
|
||||
use function is_int;
|
||||
use function is_object;
|
||||
use function lcfirst;
|
||||
use function str_replace;
|
||||
|
||||
final class Row
|
||||
{
|
||||
public static function from(mixed $value): Row
|
||||
{
|
||||
return new self(match (true) {
|
||||
is_object($value),
|
||||
is_array($value) => $value,
|
||||
default => throw new TypeError('The value must be an array or an object; received '.gettype($value).'.'),
|
||||
});
|
||||
}
|
||||
|
||||
private function __construct(private readonly array|object $row)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to retrieve a single value from a record.
|
||||
*
|
||||
* @throws ReflectionException
|
||||
* @throws QueryException If the value can not be retrieved
|
||||
* @see Row::select()
|
||||
*
|
||||
*/
|
||||
public function value(string|int $key): mixed
|
||||
{
|
||||
return $this->select($key)[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to retrieve multiple values from a record.
|
||||
*
|
||||
* If the value is an array and the key is an integer the content will be retrieved
|
||||
* from the array_values array form. Negative offset are supported.
|
||||
* If the value is an object, the key MUST be a string.
|
||||
*
|
||||
* @throws ReflectionException
|
||||
* @throws QueryException If the value can not be retrieved
|
||||
*
|
||||
* @return non-empty-array<array-key, mixed>
|
||||
*/
|
||||
public function select(string|int ...$key): array
|
||||
{
|
||||
return match (true) {
|
||||
is_object($this->row) => self::getObjectPropertyValue($this->row, ...$key),
|
||||
default => self::getArrayEntry($this->row, ...$key),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws QueryException
|
||||
*
|
||||
* @return non-empty-array<array-key, mixed>
|
||||
*/
|
||||
private function getArrayEntry(array $row, string|int ...$keys): array
|
||||
{
|
||||
$res = [];
|
||||
$arrValues = array_values($row);
|
||||
foreach ($keys as $key) {
|
||||
if (array_key_exists($key, $res)) {
|
||||
continue;
|
||||
}
|
||||
$offset = $key;
|
||||
if (is_int($offset)) {
|
||||
if (!array_is_list($row)) {
|
||||
$row = $arrValues;
|
||||
}
|
||||
|
||||
if ($offset < 0) {
|
||||
$offset += count($row);
|
||||
}
|
||||
}
|
||||
|
||||
$res[$key] = array_key_exists($offset, $row) ? $row[$offset] : throw QueryException::dueToUnknownColumn($key, $row);
|
||||
}
|
||||
|
||||
return [] !== $res ? $res : throw QueryException::dueToMissingColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
* @throws QueryException
|
||||
*
|
||||
* @return non-empty-array<array-key, mixed>
|
||||
*/
|
||||
private static function getObjectPropertyValue(object $row, string|int ...$keys): array
|
||||
{
|
||||
$res = [];
|
||||
$object = new ReflectionObject($row);
|
||||
foreach ($keys as $key) {
|
||||
if (array_key_exists($key, $res)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
!is_int($key) || throw QueryException::dueToUnknownColumn($key, $row);
|
||||
|
||||
if ($object->hasProperty($key) && $object->getProperty($key)->isPublic()) {
|
||||
$res[$key] = $object->getProperty($key)->getValue($row);
|
||||
continue;
|
||||
}
|
||||
|
||||
$methodNameList = [$key];
|
||||
if (($camelCasedKey = self::camelCase($key)) !== $key) {
|
||||
$methodNameList[] = $camelCasedKey;
|
||||
}
|
||||
$methodNameList[] = self::camelCase($key, 'get');
|
||||
foreach ($methodNameList as $methodName) {
|
||||
if ($object->hasMethod($methodName)
|
||||
&& $object->getMethod($methodName)->isPublic()
|
||||
&& 1 > $object->getMethod($methodName)->getNumberOfRequiredParameters()
|
||||
) {
|
||||
$res[$key] = $object->getMethod($methodName)->invoke($row);
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (method_exists($row, '__call')) {
|
||||
$res[$key] = $object->getMethod('__call')->invoke($row, $methodNameList[1]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($row instanceof ArrayAccess && $row->offsetExists($key)) {
|
||||
$res[$key] = $row->offsetGet($key);
|
||||
continue;
|
||||
}
|
||||
|
||||
throw QueryException::dueToUnknownColumn($key, $row);
|
||||
}
|
||||
|
||||
return [] !== $res ? $res : throw QueryException::dueToMissingColumn();
|
||||
}
|
||||
|
||||
private static function camelCase(string $value, string $prefix = ''): string
|
||||
{
|
||||
if ('' !== $prefix) {
|
||||
$prefix .= '_';
|
||||
}
|
||||
|
||||
return lcfirst(implode('', array_map(
|
||||
ucfirst(...),
|
||||
explode(' ', str_replace(['-', '_'], ' ', $prefix.$value))
|
||||
)));
|
||||
}
|
||||
}
|
||||
43
vendor/league/csv/src/Query/Sort.php
vendored
Normal file
43
vendor/league/csv/src/Query/Sort.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query;
|
||||
|
||||
use Iterator;
|
||||
|
||||
/**
|
||||
* Enable sorting a record based on its value.
|
||||
*
|
||||
* The class can be used directly with PHP's
|
||||
* <ol>
|
||||
* <li>usort and uasort.</li>
|
||||
* <li>ArrayIterator::uasort.</li>
|
||||
* <li>ArrayObject::uasort.</li>
|
||||
* </ol>
|
||||
*/
|
||||
interface Sort
|
||||
{
|
||||
/**
|
||||
* The class comparison method.
|
||||
*
|
||||
* The method must return an integer less than, equal to, or greater than zero
|
||||
* if the first argument is considered to be respectively less than, equal to,
|
||||
* or greater than the second.
|
||||
*/
|
||||
public function __invoke(mixed $valueA, mixed $valueB): int;
|
||||
|
||||
/**
|
||||
* Sort an iterable structure with the class comparison method and maintain index association.
|
||||
*/
|
||||
public function sort(iterable $value): Iterator;
|
||||
}
|
||||
45
vendor/league/csv/src/Query/SortCombinator.php
vendored
Normal file
45
vendor/league/csv/src/Query/SortCombinator.php
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* League.Csv (https://csv.thephpleague.com)
|
||||
*
|
||||
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Csv\Query;
|
||||
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* @phpstan-type Ordering Sort|Closure(mixed, mixed): int
|
||||
* @phpstan-type OrderingExtended Sort|Closure(mixed, mixed): int|callable(mixed, mixed): int
|
||||
*/
|
||||
interface SortCombinator extends Sort
|
||||
{
|
||||
/**
|
||||
* Return an instance with the specified sorting algorithm
|
||||
* added after the currently registered sorting algorithms.
|
||||
*
|
||||
* This method MUST retain the state of the current instance,
|
||||
* and return an instance that contains the specified changes.
|
||||
*
|
||||
* @param Ordering ...$sorts
|
||||
*/
|
||||
public function append(Sort|Closure ...$sorts): self;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified sorting algorithm
|
||||
* added before the currently registered sorting algorithms.
|
||||
*
|
||||
* This method MUST retain the state of the current instance,
|
||||
* and return an instance that contains the specified changes.
|
||||
*
|
||||
* @param Ordering ...$sorts
|
||||
*/
|
||||
public function prepend(Sort|Closure ...$sorts): self;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue