private static function parseUploadedFile(array $uploadedFileInfo): ?UploadedFileInterface
    {
        $error = is_array($uploadedFileInfo['error']) ? $uploadedFileInfo['error'][0] : $uploadedFileInfo['error'];
        $error = intval($error);

        if ($error !== 0) {
            if (isset(self::$fileUploadErrors[$error])) {
                throw new ServerEnvironmentException('File upload failed: ' . self::$fileUploadErrors[$error]);
            }

            return null;
        }

        $path = is_array($uploadedFileInfo['tmp_name']) ? $uploadedFileInfo['tmp_name'][0] : $uploadedFileInfo['tmp_name'];
        if (!is_uploaded_file($path)) {
            return null;
        }

        $originalName = is_array($uploadedFileInfo['name']) ? $uploadedFileInfo['name'][0] : $uploadedFileInfo['name'];
        $size = is_array($uploadedFileInfo['size']) ? $uploadedFileInfo['size'][0] : $uploadedFileInfo['size'];

        $result = new UploadedFile(
            FilePath::parse(strval($path)),
            strval($originalName),
            intval($size)
        );

        return $result;
    }