<?php

namespace AutoAdmin\Bundle\Media\Model;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;


#[ORM\MappedSuperclass]
abstract class AbstractFile extends AbstractMedia implements FileInterface
{
    #[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
    protected ?string $title = null;

    #[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
    protected ?string $name = null;

    protected ?File $file = null;

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

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

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

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

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

    public function __toString(): string
    {
        return '#' . $this->getId() . ' - ' . $this->getFileName();
    }

    public function getFileName(): ?string
    {
        return $this->fileName;
    }

    public function setFileName(?string $name): void
    {
        $this->fileName = $name;
    }

    public function getTitle(): ?string
    {
        return $this->title;
    }

    public function setTitle(?string $title): void
    {
        $this->title = $title;
    }

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

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

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

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

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

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

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

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

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

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

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

        return $this->extension;
    }


}
