<?php

namespace App\VichUploader\Namer\Account;

use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Uid\Uuid;
use Vich\UploaderBundle\Mapping\PropertyMapping;
use Vich\UploaderBundle\Naming\NamerInterface;
use Vich\UploaderBundle\Templating\Helper\UploaderHelper;

class AvatarName implements NamerInterface
{

    public function name(object $object, PropertyMapping $mapping): string
    {
        /** @var UploadedFile $file */
        $file = $mapping->getFile($object);
        $extension = pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
        $uuid = Uuid::v4()->toString();
        return "avatar-".$uuid.".".$extension;
    }
}
