learning-center/app/SharedKernel/Http/RequestFilesNormalizer.php

24 lines
513 B
PHP
Raw Permalink Normal View History

2024-09-08 13:48:26 +03:00
<?php
declare(strict_types=1);
namespace App\SharedKernel\Http;
final class RequestFilesNormalizer
{
public static function normalize(array $requestFiles): array
{
$normalizedFiles = [];
$count = count($requestFiles['name']);
$keys = array_keys($requestFiles);
for ($i = 0; $i < $count; $i++) {
foreach ($keys as $key) {
$normalizedFiles[$i][$key] = $requestFiles[$key][$i];
}
}
return $normalizedFiles;
}
}