This commit is contained in:
2024-06-13 08:05:27 +02:00
parent b0f09a8217
commit a73dac370c
2 changed files with 9 additions and 3 deletions

View File

@@ -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,

View File

@@ -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;
}