<?php

namespace AutoAdmin\Bundle\Media\Model\Library;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\Ignore;

#[ORM\MappedSuperclass]
abstract class AbstractFileTranslatable extends AbstractMediaTranslatable implements FileMediaInterface
{
    protected ?File $file = null;

    #[ORM\Column(type: Types::INTEGER)]
    #[Ignore()]
    protected int $mediaChangedAt = 0;

    #[ORM\Column(type: Types::STRING, nullable: true)]
    #[Groups(['media'])]
    protected ?string $originalName = null;

    #[ORM\Column(type: Types::STRING, nullable: true)]
    #[Groups(['media'])]
    protected ?string $mimeType = null;

    #[ORM\Column(type: Types::INTEGER, nullable: true)]
    #[Groups(['media'])]
    protected ?int $size = null;

    #[ORM\Column(type: Types::STRING, nullable: true)]
    #[Groups(['media'])]
    protected ?string $extension = null;

    public function getFile(): ?File
    {
        return $this->file;
    }

    public function setFile(File $file = null): self
    {
        $this->file = $file;

        if ($file) {
            $this->mediaChangedAt = time();
        }

        return $this;
    }

    public function getMediaChangedAt(): int
    {
        return $this->mediaChangedAt;
    }

    public function setMediaChangedAt(mixed $mediaChangedAt): self
    {
        $this->mediaChangedAt = $mediaChangedAt;

        return $this;
    }

    public function getOriginalName(): ?string
    {
        return $this->originalName;
    }

    public function setOriginalName(?string $originalName): self
    {
        $this->originalName = $originalName;

        return $this;
    }

    public function getMimeType(): ?string
    {
        return $this->mimeType;
    }

    public function setMimeType(?string $mimeType): self
    {
        $this->mimeType = $mimeType;

        return $this;
    }

    public function getSize(): ?int
    {
        return $this->size;
    }

    public function setSize(?int $size): self
    {
        $this->size = $size;

        return $this;
    }

    public function getExtension(): ?string
    {
        return $this->extension;
    }

    public function setExtension(?string $extension): ?string
    {
        $this->extension = $extension;

        return $this->extension;
    }
}
