<?php

namespace MintyPHP\Service\Audit;

use MintyPHP\Repository\Audit\ApiAuditLogRepository;
use MintyPHP\Repository\Audit\UserLifecycleAuditRepository;

class AuditServicesFactory
{
    private ?ApiAuditLogRepository $apiAuditLogRepository = null;
    private ?UserLifecycleAuditRepository $userLifecycleAuditRepository = null;
    private ?ApiAuditService $apiAuditService = null;
    private ?UserLifecycleAuditService $userLifecycleAuditService = null;

    public function createApiAuditLogRepository(): ApiAuditLogRepository
    {
        return $this->apiAuditLogRepository ??= new ApiAuditLogRepository();
    }

    public function createUserLifecycleAuditRepository(): UserLifecycleAuditRepository
    {
        return $this->userLifecycleAuditRepository ??= new UserLifecycleAuditRepository();
    }

    public function createApiAuditService(): ApiAuditService
    {
        return $this->apiAuditService ??= new ApiAuditService($this->createApiAuditLogRepository());
    }

    public function createUserLifecycleAuditService(): UserLifecycleAuditService
    {
        return $this->userLifecycleAuditService ??= new UserLifecycleAuditService(
            $this->createUserLifecycleAuditRepository()
        );
    }
}
