| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- declare(strict_types=1);
- namespace App\Service\Utils;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Contracts\HttpClient\HttpClientInterface;
- /**
- * Class Siret : méthodes d'aide pour la gestion de numéro de Siret.
- * @package App\Service\Utils
- */
- class Siret
- {
- private HttpClientInterface $clientSiret;
- public function __construct(
- HttpClientInterface $siret_checking
- )
- {
- $this->clientSiret = $siret_checking;
- }
- /**
- * Vérifie si le numéro de Siret passé en paramètre est valide
- * @param string $siret
- * @return bool
- * @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface
- * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface
- * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
- * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
- * @see SiretTest::testIsSiretIsCorrect()
- */
- public function isSiretIsCorrect(string $siret): bool {
- $response = $this->clientSiret->request('GET', $siret);
- return $response->getStatusCode() === Response::HTTP_OK;
- }
- }
|