Skip to content

Commit

Permalink
Make "uploaded" key optional in FileUploadNormalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar committed Apr 12, 2024
1 parent b169629 commit 43129bd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Util/FileUploadNormalizer.php
Expand Up @@ -14,7 +14,7 @@

class FileUploadNormalizer
{
private const REQUIRED_KEYS = ['name', 'type', 'tmp_name', 'error', 'size', 'uploaded', 'uuid'];
private const REQUIRED_KEYS = ['name', 'type', 'tmp_name', 'error', 'size', 'uuid'];

public function __construct(
private readonly string $projectDir,
Expand All @@ -38,6 +38,7 @@ public function normalize(array $files): array
switch (true) {
case $this->hasRequiredKeys($file):
$file['stream'] = $this->fopen($file['tmp_name']);
$file['uploaded'] ??= true;
$standardizedPerKey[$k][] = $file;
break;
case $this->isPhpUpload($file):
Expand Down Expand Up @@ -100,7 +101,7 @@ private function hasRequiredKeys(mixed $file): bool
return false;
}

return self::REQUIRED_KEYS === array_keys($file);
return [] === array_diff(self::REQUIRED_KEYS, array_keys($file));
}

private function extractUuid(mixed $candidate): Uuid|null
Expand Down

0 comments on commit 43129bd

Please sign in to comment.