<?php

namespace Src\Modules\Auth\Application;

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

class Factory implements IFactory
{
    protected IModuleFactory $moduleFactory;

    private ?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->setApplicationFactory($this);
        return $this->adminFactory;
    }
}