Skip to content

implement proper filtering abstraction

Jiří Pudil requested to merge conditions-api into master

closes #2 (closed), builds upon !19 (merged)

Provides API with shorthands for 99% of use cases (equality, comparison, in/not in, null-checking):

$now = $clock->getTime();
$valid = $table->findBy([
	$table->expiresAt()->is(greaterThan($now)),
]);

But there are interfaces underneath those shorthands, so you can provide custom operation:

$matches = $table->findBy([
    $table->name()->is(like($value)), // <-- like() is my custom function that returns instanceof Operation
]);

or even custom expressions:

$lastYears = $table->findBy([
    new SingleCondition(year($table->issuedAt()), equalTo(2021)), // <-- year() is my custom function that maps to YEAR() database function
]);

cc @dkurowski

Edited by Jiří Pudil

Merge request reports

Loading