From 6d962856db6be4b979a61d8d24484736cdfe4dff Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 15 Jul 2021 11:44:26 -0700 Subject: [PATCH] Dont use `empty()` (#8) * Dont use `empty()` * cs --- src/EntityExistValidator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EntityExistValidator.php b/src/EntityExistValidator.php index 2e60a23..27852ea 100644 --- a/src/EntityExistValidator.php +++ b/src/EntityExistValidator.php @@ -23,14 +23,14 @@ public function __construct(EntityManagerInterface $entityManager) public function validate($value, Constraint $constraint): void { - if (empty($value)) { - return; - } - if (!$constraint instanceof EntityExist) { throw new \LogicException(\sprintf('You can only pass %s constraint to this validator.', EntityExist::class)); } + if (null === $value || '' === $value) { + return; + } + if (empty($constraint->entity)) { throw new \LogicException(\sprintf('Must set "entity" on "%s" validator', EntityExist::class)); }