forked from fa/breadcrumb-the-shire
35 lines
1019 B
PHP
35 lines
1019 B
PHP
<?php
|
|
|
|
namespace MintyPHP\Service\Security;
|
|
|
|
use MintyPHP\Repository\Security\RateLimitRepositoryInterface;
|
|
|
|
class SecurityServicesFactory
|
|
{
|
|
private ?RateLimiterService $rateLimiterService = null;
|
|
private ?RateLimiterFallbackGateway $rateLimiterFallbackGateway = null;
|
|
|
|
public function __construct(
|
|
private readonly SecurityRepositoryFactory $securityRepositoryFactory
|
|
) {
|
|
}
|
|
|
|
public function createRateLimitRepository(): RateLimitRepositoryInterface
|
|
{
|
|
return $this->securityRepositoryFactory->createRateLimitRepository();
|
|
}
|
|
|
|
public function createRateLimiterService(): RateLimiterService
|
|
{
|
|
return $this->rateLimiterService ??= new RateLimiterService(
|
|
$this->createRateLimitRepository(),
|
|
$this->createRateLimiterFallbackGateway()
|
|
);
|
|
}
|
|
|
|
public function createRateLimiterFallbackGateway(): RateLimiterFallbackGateway
|
|
{
|
|
return $this->rateLimiterFallbackGateway ??= new RateLimiterFallbackGateway();
|
|
}
|
|
}
|