From 00bbff97e257f895dd7aee5d6aff6ad068465344 Mon Sep 17 00:00:00 2001 From: ignace nyamagana butera Date: Wed, 22 May 2024 07:28:21 +0200 Subject: [PATCH] Simplify Query related interface --- src/Query/Constraint/Column.php | 9 --------- src/Query/Constraint/Criteria.php | 9 --------- src/Query/Constraint/TwoColumns.php | 9 --------- src/Query/Limit.php | 10 ---------- src/Query/Ordering/Column.php | 8 -------- src/Query/Ordering/MultiSort.php | 16 ---------------- src/Query/Predicate.php | 2 -- src/Query/Sort.php | 2 -- 8 files changed, 65 deletions(-) diff --git a/src/Query/Constraint/Column.php b/src/Query/Constraint/Column.php index 92d741e2..7f916b8c 100644 --- a/src/Query/Constraint/Column.php +++ b/src/Query/Constraint/Column.php @@ -78,13 +78,4 @@ public function filter(iterable $value): Iterator default => new ArrayIterator($value), }, $this); } - - public function filterArray(iterable $value): array - { - return array_filter( - !is_array($value) ? iterator_to_array($value) : $value, - $this, - ARRAY_FILTER_USE_BOTH - ); - } } diff --git a/src/Query/Constraint/Criteria.php b/src/Query/Constraint/Criteria.php index 7bf81bbd..3c4e61a9 100644 --- a/src/Query/Constraint/Criteria.php +++ b/src/Query/Constraint/Criteria.php @@ -122,15 +122,6 @@ public function filter(iterable $value): Iterator }, $this); } - public function filterArray(iterable $values): array - { - return array_filter( - !is_array($values) ? iterator_to_array($values) : $values, - $this, - ARRAY_FILTER_USE_BOTH - ); - } - /** * @param ConditionExtended ...$predicates */ diff --git a/src/Query/Constraint/TwoColumns.php b/src/Query/Constraint/TwoColumns.php index 256a5ef4..cdd4ef81 100644 --- a/src/Query/Constraint/TwoColumns.php +++ b/src/Query/Constraint/TwoColumns.php @@ -91,13 +91,4 @@ public function filter(iterable $value): Iterator default => new ArrayIterator($value), }, $this); } - - public function filterArray(iterable $value): array - { - return array_filter( - !is_array($value) ? iterator_to_array($value) : $value, - $this, - ARRAY_FILTER_USE_BOTH - ); - } } diff --git a/src/Query/Limit.php b/src/Query/Limit.php index 88874650..c39f39a8 100644 --- a/src/Query/Limit.php +++ b/src/Query/Limit.php @@ -55,14 +55,4 @@ public function slice(iterable $value): LimitIterator $this->length, ); } - - public function sliceArray(iterable $values): array - { - return array_slice( - !is_array($values) ? iterator_to_array($values) : $values, - $this->offset, - $this->length === -1 ? null : $this->length, - true - ); - } } diff --git a/src/Query/Ordering/Column.php b/src/Query/Ordering/Column.php index efd110d1..99718289 100644 --- a/src/Query/Ordering/Column.php +++ b/src/Query/Ordering/Column.php @@ -103,12 +103,4 @@ public function seek(int $offset): void return $it; } - - public function sortArray(iterable $value): array - { - $sorted = !is_array($value) ? iterator_to_array($value) : $value; - uasort($sorted, $this); - - return $sorted; - } } diff --git a/src/Query/Ordering/MultiSort.php b/src/Query/Ordering/MultiSort.php index 291464c3..ad96723e 100644 --- a/src/Query/Ordering/MultiSort.php +++ b/src/Query/Ordering/MultiSort.php @@ -121,20 +121,4 @@ public function seek(int $offset): void return $it; } - - public function sortArray(iterable $value): array - { - if (!is_array($value)) { - $value = iterator_to_array($value); - } - - if ([] === $this->sorts) { - return $value; - } - - $sorted = $value; - uasort($sorted, $this); - - return $sorted; - } } diff --git a/src/Query/Predicate.php b/src/Query/Predicate.php index 432a6cf9..b179104a 100644 --- a/src/Query/Predicate.php +++ b/src/Query/Predicate.php @@ -29,6 +29,4 @@ interface Predicate public function __invoke(mixed $value, string|int $key): bool; public function filter(iterable $value): Iterator; - - public function filterArray(iterable $value): array; } diff --git a/src/Query/Sort.php b/src/Query/Sort.php index 6508e9a8..93b98d3b 100644 --- a/src/Query/Sort.php +++ b/src/Query/Sort.php @@ -30,6 +30,4 @@ interface Sort public function __invoke(mixed $valueA, mixed $valueB): int; public function sort(iterable $value): Iterator; - - public function sortArray(iterable $value): array; }