diff --git a/src/Service/SightEngineImageSafetyService.php b/src/Service/SightEngineImageSafetyService.php index 957081a..ef7cfcc 100644 --- a/src/Service/SightEngineImageSafetyService.php +++ b/src/Service/SightEngineImageSafetyService.php @@ -19,6 +19,9 @@ readonly class SightEngineImageSafetyService implements ImageSafetyServiceInterf public function isValid(File $file): bool { $handle = fopen($file->getRealPath(), 'r'); + if ($handle === false) { + return false; + } $response = $this->client->request('POST', 'https://api.sightengine.com/1.0/check.json', [ 'body' => [ 'media' => $handle, diff --git a/src/Validator/ImageSafetyValidator.php b/src/Validator/ImageSafetyValidator.php index 8511bdc..9139fe0 100644 --- a/src/Validator/ImageSafetyValidator.php +++ b/src/Validator/ImageSafetyValidator.php @@ -12,10 +12,13 @@ class ImageSafetyValidator extends ConstraintValidator { } - public function validate($value, Constraint $constraint): void + /** + * @param mixed $value + * @param ImageSafety $constraint + * @return void + */ + public function validate(mixed $value, Constraint $constraint): void { - /* @var ImageSafety $constraint */ - if (null === $value || '' === $value) { return; }