2026-02-23 12:58:19 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Service\Security;
|
|
|
|
|
|
2026-03-05 08:26:51 +01:00
|
|
|
use MintyPHP\Repository\Security\RateLimitRepositoryInterface;
|
2026-02-23 12:58:19 +01:00
|
|
|
|
|
|
|
|
class SecurityServicesFactory
|
|
|
|
|
{
|
|
|
|
|
private ?RateLimiterService $rateLimiterService = null;
|
2026-04-25 23:17:46 +02:00
|
|
|
private ?RateLimiterFallbackGateway $rateLimiterFallbackGateway = null;
|
2026-02-23 12:58:19 +01:00
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
public function __construct(
|
|
|
|
|
private readonly SecurityRepositoryFactory $securityRepositoryFactory
|
2026-03-05 11:17:42 +01:00
|
|
|
) {
|
|
|
|
|
}
|
2026-03-04 15:56:58 +01:00
|
|
|
|
2026-03-05 08:26:51 +01:00
|
|
|
public function createRateLimitRepository(): RateLimitRepositoryInterface
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-04 15:56:58 +01:00
|
|
|
return $this->securityRepositoryFactory->createRateLimitRepository();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createRateLimiterService(): RateLimiterService
|
|
|
|
|
{
|
2026-04-25 23:17:46 +02:00
|
|
|
return $this->rateLimiterService ??= new RateLimiterService(
|
|
|
|
|
$this->createRateLimitRepository(),
|
|
|
|
|
$this->createRateLimiterFallbackGateway()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createRateLimiterFallbackGateway(): RateLimiterFallbackGateway
|
|
|
|
|
{
|
|
|
|
|
return $this->rateLimiterFallbackGateway ??= new RateLimiterFallbackGateway();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
}
|