Skip to content

Commit c926404

Browse files
committed
Enum support for Condition class
1 parent db9728d commit c926404

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "<=11.0",
20+
"phpunit/phpunit": "<=11.99",
2121
"phpfui/phpunit-syntax-coverage": "^1.0",
2222
"roave/security-advisories": "dev-latest",
2323
"friendsofphp/php-cs-fixer": "^3.0",

src/PHPFUI/ORM/Condition.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ public function orNot(string | \PHPFUI\ORM\Condition | \PHPFUI\ORM\Literal $cond
210210
*/
211211
private function add(string $logical, string | \PHPFUI\ORM\Condition | \PHPFUI\ORM\Literal $condition, \PHPFUI\ORM\Operator $operator, mixed $value) : static
212212
{
213+
// convert enum to the backed type
214+
if (\is_object($value) && \enum_exists($value::class))
215+
{
216+
$value = $value->value;
217+
}
218+
213219
if (null === $value && ! $operator->correctlyTyped($value))
214220
{
215221
if ($operator instanceof \PHPFUI\ORM\Operator\Equal)

0 commit comments

Comments
 (0)