<?php

namespace AutoAdmin\Bundle\Content\Context;

use AutoAdmin\Bundle\Seo\Model\SeoPage;
use Exception;

class ContentContext
{
    private ?object $mainContent = null;
    private ?SeoPage $seoPage;
    private array $extras = [];

    public function __construct()
    {
        $this->seoPage = new SeoPage();
    }

    public function getMainContent(): ?object
    {
        return $this->mainContent;
    }

    public function setMainContent(object $mainContent): void
    {
        $this->mainContent = $mainContent;
    }

    public function getSeoPage(): ?SeoPage
    {
        return $this->seoPage;
    }

    public function setSeoPage(?SeoPage $seoPage): void
    {
        $this->seoPage = $seoPage;
    }

    /**
     * @deprecated Not used or report if used
     */
    public function getExtra(string $name)
    {
        return $this->extras[$name] ?? null;
    }

    /**
     * @deprecated Not used or report if used
     */
    public function setExtra(string $name, $value, $throwIfReplace = false)
    {
        if (array_key_exists($name, $this->extras) && $throwIfReplace !== false) {
            throw new Exception('Could not replace value without explicit intention.');
        }

        return $this->extras[$name] = $value;
    }

    /**
     * @deprecated Not used or report if used
     */
    public function getExtras(): array
    {
        return $this->extras;
    }

    /**
     * @deprecated Not used or report if used
     */
    public function setExtras(array $extras): void
    {
        $this->extras = $extras;
    }
}
