<?php

namespace Src\Modules\Auth\Dto;

use Src\Modules\Auth\Interfaces\Dto\IFactory;
use Src\Modules\Auth\Interfaces\IFactory as IModuleFactory;
use Src\Modules\Auth\Interfaces\Dto\Admin\IFactory as IAdminFactory;
use Src\Modules\Auth\Dto\Admin\Factory as AdminFactory;

class Factory implements IFactory
{
    protected IModuleFactory $moduleFactory;

    protected ?IAdminFactory $adminFactory = null;

    public function setModuleFactory(IModuleFactory $factory): void
    {
        $this->moduleFactory = $factory;
    }

    public function getModuleFactory(): IModuleFactory
    {
        return $this->moduleFactory;
    }

    public function getAdminFactory(): AdminFactory
    {
        if($this->adminFactory){
            return $this->adminFactory;
        }
        $this->adminFactory = new AdminFactory();
        $this->adminFactory->setDtoFactory($this);
        return $this->adminFactory;
    }
}