Skip to content

Commit

Permalink
Simplify Query related interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed May 22, 2024
1 parent 19e27c1 commit 00bbff9
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 65 deletions.
9 changes: 0 additions & 9 deletions src/Query/Constraint/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
9 changes: 0 additions & 9 deletions src/Query/Constraint/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
9 changes: 0 additions & 9 deletions src/Query/Constraint/TwoColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
10 changes: 0 additions & 10 deletions src/Query/Limit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
8 changes: 0 additions & 8 deletions src/Query/Ordering/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
16 changes: 0 additions & 16 deletions src/Query/Ordering/MultiSort.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 0 additions & 2 deletions src/Query/Predicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 0 additions & 2 deletions src/Query/Sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 00bbff9

Please sign in to comment.