<?php

declare(strict_types=1);

namespace KupShop\ContentBundle\Entity;

use KupShop\KupShopBundle\Template\ArrayAccess;
use KupShop\KupShopBundle\Util\System\PathFinder;

class Image extends ArrayAccess
{
    public $id;
    public $videoId;
    public $description;
    public $source;
    public $imageDesktop;
    public $imageTablet;
    public $imageMobile;
    public ?\DateTime $date = null;
    public $dateUpdated;
    public array $data = [];

    public function getId(): int
    {
        return $this->id;
    }

    public function setId(int $id): self
    {
        $this->id = $id;

        return $this;
    }

    public function getVideoId(): ?string
    {
        return $this->videoId;
    }

    public function setVideoId(?string $videoId): self
    {
        $this->videoId = $videoId;

        return $this;
    }

    public function getDescription(): string
    {
        return $this->description;
    }

    public function setDescription(string $description): self
    {
        $this->description = $description;

        return $this;
    }

    public function setSource(string $source): self
    {
        $this->source = $source;

        return $this;
    }

    public function getSource(): string
    {
        return $this->source;
    }

    public function getImageDesktop(): string
    {
        return $this->imageDesktop;
    }

    public function setImageDesktop(string $imageDesktop): self
    {
        $this->imageDesktop = $imageDesktop;

        return $this;
    }

    public function getImageTablet(): ?string
    {
        return $this->imageTablet;
    }

    public function setImageTablet(?string $imageTablet): self
    {
        $this->imageTablet = $imageTablet;

        return $this;
    }

    public function getImageMobile(): ?string
    {
        return $this->imageMobile;
    }

    public function setImageMobile(?string $imageMobile): self
    {
        $this->imageMobile = $imageMobile;

        return $this;
    }

    public function getDate(): ?\DateTime
    {
        return $this->date;
    }

    public function setDate(?\DateTime $date): self
    {
        $this->date = $date;

        return $this;
    }

    public function getDateUpdated(): \DateTime
    {
        return $this->dateUpdated;
    }

    public function setDateUpdated(\DateTime $dateUpdated): self
    {
        $this->dateUpdated = $dateUpdated;

        return $this;
    }

    public function getData(): array
    {
        return $this->data;
    }

    public function setData(array $data): self
    {
        $this->data = $data;

        return $this;
    }

    public function getImagePath(): string
    {
        return PathFinder::getService()->dataPath('photos/'.$this->source.$this->imageDesktop);
    }

    public function getHash(): string
    {
        return md5(
            implode('-', [$this->getId(), $this->getDate()?->format('Y-m-d H:i:s') ?: '']),
        );
    }
}
