Skip to content

Commit

Permalink
Allowing Dates in Range
Browse files Browse the repository at this point in the history
This allows a Date to be compared by range without the need to convert it to Unix timestamp (Numeric value).
  • Loading branch information
karemont authored and Jeroen-G committed Nov 25, 2024
1 parent 250ef43 commit 25cc12c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Domain/Syntax/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ class Range implements SyntaxInterface

private ?float $boost;

public function __construct(string $field, array $definitions, ?float $boost = 1.0)
private ?bool $date;

public function __construct(string $field, array $definitions, ?float $boost = 1.0, ?bool $date = false)
{
$this->field = $field;
$this->definitions = $definitions;
$this->boost = $boost;
$this->date = $date;
$this->validateDefinitions($definitions);
}

Expand All @@ -36,7 +39,10 @@ private function validateDefinitions(array $definitions): void
foreach ($definitions as $key => $value) {
Assert::inArray($key, self::RELATIONS);
Assert::notNull($value);
Assert::numeric($value);

if (!$this->date) {
Assert::numeric($value);
}
}
}
}

0 comments on commit 25cc12c

Please sign in to comment.