ci: add php cs fixer

This commit is contained in:
Maël Gangloff
2024-08-02 23:24:52 +02:00
parent cd5060ed6a
commit b460e8aaa6
41 changed files with 1413 additions and 440 deletions

View File

@@ -7,8 +7,6 @@ use App\Entity\WatchList;
use App\Message\ProcessDomainTrigger;
use App\Repository\DomainRepository;
use App\Service\RDAPService;
use DateTimeImmutable;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
use Symfony\Component\HttpKernel\KernelInterface;
@@ -21,11 +19,10 @@ use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
class DomainRefreshController extends AbstractController
{
public function __construct(private readonly DomainRepository $domainRepository,
private readonly RDAPService $RDAPService,
private readonly RateLimiterFactory $authenticatedApiLimiter,
private readonly MessageBusInterface $bus)
public function __construct(private readonly DomainRepository $domainRepository,
private readonly RDAPService $RDAPService,
private readonly RateLimiterFactory $authenticatedApiLimiter,
private readonly MessageBusInterface $bus)
{
}
@@ -34,26 +31,30 @@ class DomainRefreshController extends AbstractController
* @throws HttpExceptionInterface
* @throws DecodingExceptionInterface
* @throws ExceptionInterface
* @throws Exception
* @throws \Exception
*/
public function __invoke(string $ldhName, KernelInterface $kernel): ?Domain
{
/** @var Domain $domain */
$domain = $this->domainRepository->findOneBy(["ldhName" => $ldhName]);
$domain = $this->domainRepository->findOneBy(['ldhName' => $ldhName]);
// If the domain name exists in the database, recently updated and not important, we return the stored Domain
if ($domain !== null &&
!$domain->getDeleted() &&
($domain->getUpdatedAt()->diff(new DateTimeImmutable('now'))->days < 7) &&
!$this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt())
) return $domain;
if (null !== $domain
&& !$domain->getDeleted()
&& ($domain->getUpdatedAt()->diff(new \DateTimeImmutable('now'))->days < 7)
&& !$this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt())
) {
return $domain;
}
if (false === $kernel->isDebug()) {
$limiter = $this->authenticatedApiLimiter->create($this->getUser()->getUserIdentifier());
if (false === $limiter->consume()->isAccepted()) throw new TooManyRequestsHttpException();
if (false === $limiter->consume()->isAccepted()) {
throw new TooManyRequestsHttpException();
}
}
$updatedAt = $domain === null ? new DateTimeImmutable('now') : $domain->getUpdatedAt();
$updatedAt = null === $domain ? new \DateTimeImmutable('now') : $domain->getUpdatedAt();
$domain = $this->RDAPService->registerDomain($ldhName);
/** @var WatchList $watchList */
@@ -63,4 +64,4 @@ class DomainRefreshController extends AbstractController
return $domain;
}
}
}