<?php

namespace App\Config\Entity;

use Doctrine\ORM\Mapping as ORM;

use App\Config\Repository\SiteConfigRepository;
#[ORM\Entity(repositoryClass: SiteConfigRepository::class)]
#[ORM\Table(name: 'site_config')]
class SiteConfig
{
    #[ORM\Id]
    #[ORM\Column(name: 'config_key', type: 'string', length: 100)]
    private string $configKey;

    #[ORM\Column(name: 'config_value', type: 'text', nullable: true)]
    private ?string $configValue;

    #[ORM\Column(name: 'updated_at', type: 'integer')]
    private int $updatedAt;

    public function __construct(string $key, ?string $value = null)
    {
        $this->configKey   = $key;
        $this->configValue = $value;
        $this->updatedAt   = time();
    }

    public function getKey(): string    { return $this->configKey; }
    public function getValue(): ?string { return $this->configValue; }

    public function setValue(?string $value): self
    {
        $this->configValue = $value;
        $this->updatedAt   = time();
        return $this;
    }
}
