vendor/setono/client-id/src/Cookie/Adapter/SymfonyCookieReader.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Setono\ClientId\Cookie\Adapter;
  4. use Setono\ClientId\Cookie\CookieReaderInterface;
  5. use Symfony\Component\HttpFoundation\RequestStack;
  6. final class SymfonyCookieReader implements CookieReaderInterface
  7. {
  8.     private RequestStack $requestStack;
  9.     public function __construct(RequestStack $requestStack)
  10.     {
  11.         $this->requestStack = $requestStack;
  12.     }
  13.     public function getValue(string $name): ?string
  14.     {
  15.         $request = $this->requestStack->getMasterRequest();
  16.         if (null === $request) {
  17.             return null;
  18.         }
  19.         if (!$request->cookies->has($name)) {
  20.             return null;
  21.         }
  22.         $cookie = $request->cookies->get($name);
  23.         if (!is_string($cookie)) {
  24.             return null;
  25.         }
  26.         return $cookie;
  27.     }
  28. }