From 61b5ec285c09a4a9b840ae51c5b57c3cd494ec17 Mon Sep 17 00:00:00 2001 From: Mikel Martin Date: Wed, 9 Oct 2024 10:27:02 +0200 Subject: [PATCH] Remove ignore and check if implements ConditionallyDeletes interface --- .../Repositories/TransactionLogRepository.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/BusinessLogic/DataAccess/TransactionLog/Repositories/TransactionLogRepository.php b/src/BusinessLogic/DataAccess/TransactionLog/Repositories/TransactionLogRepository.php index df01a61..ea0d8c8 100644 --- a/src/BusinessLogic/DataAccess/TransactionLog/Repositories/TransactionLogRepository.php +++ b/src/BusinessLogic/DataAccess/TransactionLog/Repositories/TransactionLogRepository.php @@ -3,10 +3,12 @@ namespace SeQura\Core\BusinessLogic\DataAccess\TransactionLog\Repositories; use DateTime; +use RuntimeException; use SeQura\Core\BusinessLogic\DataAccess\TransactionLog\Entities\TransactionLog; use SeQura\Core\BusinessLogic\Domain\Multistore\StoreContext; use SeQura\Core\BusinessLogic\TransactionLog\RepositoryContracts\TransactionLogRepositoryInterface; use SeQura\Core\Infrastructure\ORM\Exceptions\QueryFilterInvalidParamException; +use SeQura\Core\Infrastructure\ORM\Interfaces\ConditionallyDeletes; use SeQura\Core\Infrastructure\ORM\Interfaces\RepositoryInterface; use SeQura\Core\Infrastructure\ORM\QueryFilter\Operators; use SeQura\Core\Infrastructure\ORM\QueryFilter\QueryFilter; @@ -185,7 +187,9 @@ public function deleteLogs(DateTime $beforeDate, int $limit): void ->where('storeId', Operators::EQUALS, $this->storeContext->getStoreId()); $queryFilter->setLimit($limit); - // @phpstan-ignore-next-line + if (! $this->repository instanceof ConditionallyDeletes) { + throw new RuntimeException('Repository does not support deleteWhere method'); + } $this->repository->deleteWhere($queryFilter); } @@ -199,7 +203,9 @@ public function deleteTransactionLogById(int $id): void $queryFilter = new QueryFilter(); $queryFilter->where('id', Operators::EQUALS, $id); - // @phpstan-ignore-next-line + if (! $this->repository instanceof ConditionallyDeletes) { + throw new RuntimeException('Repository does not support deleteWhere method'); + } $this->repository->deleteWhere($queryFilter); }