From 12f8c02be72bde0c97ac9591fd8f72d0fe5d8a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wr=C3=B3blewski?= Date: Fri, 9 Feb 2024 22:25:02 +0100 Subject: [PATCH] feat: supports method in proxy query factories --- .../Doctrine/Orm/Query/DoctrineOrmProxyQueryFactory.php | 9 +++++---- src/Query/ProxyQueryFactoryInterface.php | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Bridge/Doctrine/Orm/Query/DoctrineOrmProxyQueryFactory.php b/src/Bridge/Doctrine/Orm/Query/DoctrineOrmProxyQueryFactory.php index 1dfb94aa..19b570fc 100644 --- a/src/Bridge/Doctrine/Orm/Query/DoctrineOrmProxyQueryFactory.php +++ b/src/Bridge/Doctrine/Orm/Query/DoctrineOrmProxyQueryFactory.php @@ -13,10 +13,11 @@ class DoctrineOrmProxyQueryFactory implements ProxyQueryFactoryInterface { public function create(mixed $data): ProxyQueryInterface { - if ($data instanceof QueryBuilder) { - return new DoctrineOrmProxyQuery($data); - } + return new DoctrineOrmProxyQuery($data); + } - throw new UnexpectedTypeException($data, QueryBuilder::class); + public function supports(mixed $data): bool + { + return $data instanceof QueryBuilder; } } diff --git a/src/Query/ProxyQueryFactoryInterface.php b/src/Query/ProxyQueryFactoryInterface.php index 28527724..f2dff007 100755 --- a/src/Query/ProxyQueryFactoryInterface.php +++ b/src/Query/ProxyQueryFactoryInterface.php @@ -7,4 +7,6 @@ interface ProxyQueryFactoryInterface { public function create(mixed $data): ProxyQueryInterface; + + public function supports(mixed $data): bool; }