vendor/league/oauth2-server-bundle/src/Model/AbstractClient.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace League\Bundle\OAuth2ServerBundle\Model;
  4. use League\Bundle\OAuth2ServerBundle\ValueObject\Grant;
  5. use League\Bundle\OAuth2ServerBundle\ValueObject\RedirectUri;
  6. use League\Bundle\OAuth2ServerBundle\ValueObject\Scope;
  7. /**
  8.  * @psalm-consistent-constructor
  9.  *
  10.  * @author Mathias Arlaud <mathias.arlaud@gmail.com>
  11.  */
  12. abstract class AbstractClient implements ClientInterface
  13. {
  14.     /**
  15.      * @var string
  16.      */
  17.     private $name;
  18.     /**
  19.      * @var string
  20.      */
  21.     protected $identifier;
  22.     /**
  23.      * @var string|null
  24.      */
  25.     private $secret;
  26.     /**
  27.      * @var list<RedirectUri>
  28.      */
  29.     private $redirectUris = [];
  30.     /**
  31.      * @var list<Grant>
  32.      */
  33.     private $grants = [];
  34.     /**
  35.      * @var list<Scope>
  36.      */
  37.     private $scopes = [];
  38.     /**
  39.      * @var bool
  40.      */
  41.     private $active true;
  42.     /**
  43.      * @var bool
  44.      */
  45.     private $allowPlainTextPkce false;
  46.     /**
  47.      * @psalm-mutation-free
  48.      */
  49.     public function __construct(string $namestring $identifier, ?string $secret)
  50.     {
  51.         $this->name $name;
  52.         $this->identifier $identifier;
  53.         $this->secret $secret;
  54.     }
  55.     /**
  56.      * @psalm-mutation-free
  57.      */
  58.     public function getName(): string
  59.     {
  60.         return $this->name;
  61.     }
  62.     public function setName(string $name): ClientInterface
  63.     {
  64.         $this->name $name;
  65.         return $this;
  66.     }
  67.     /**
  68.      * @psalm-mutation-free
  69.      */
  70.     public function getIdentifier(): string
  71.     {
  72.         return $this->identifier;
  73.     }
  74.     /**
  75.      * @psalm-mutation-free
  76.      */
  77.     public function getSecret(): ?string
  78.     {
  79.         return $this->secret;
  80.     }
  81.     /**
  82.      * @return list<RedirectUri>
  83.      *
  84.      * @psalm-mutation-free
  85.      */
  86.     public function getRedirectUris(): array
  87.     {
  88.         return $this->redirectUris;
  89.     }
  90.     public function setRedirectUris(RedirectUri ...$redirectUris): ClientInterface
  91.     {
  92.         /** @var list<RedirectUri> $redirectUris */
  93.         $this->redirectUris $redirectUris;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @return list<Grant>
  98.      *
  99.      * @psalm-mutation-free
  100.      */
  101.     public function getGrants(): array
  102.     {
  103.         return $this->grants;
  104.     }
  105.     public function setGrants(Grant ...$grants): ClientInterface
  106.     {
  107.         /** @var list<Grant> $grants */
  108.         $this->grants $grants;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return list<Scope>
  113.      *
  114.      * @psalm-mutation-free
  115.      */
  116.     public function getScopes(): array
  117.     {
  118.         return $this->scopes;
  119.     }
  120.     public function setScopes(Scope ...$scopes): ClientInterface
  121.     {
  122.         /** @var list<Scope> $scopes */
  123.         $this->scopes $scopes;
  124.         return $this;
  125.     }
  126.     /**
  127.      * @psalm-mutation-free
  128.      */
  129.     public function isActive(): bool
  130.     {
  131.         return $this->active;
  132.     }
  133.     public function setActive(bool $active): ClientInterface
  134.     {
  135.         $this->active $active;
  136.         return $this;
  137.     }
  138.     /**
  139.      * @psalm-mutation-free
  140.      */
  141.     public function isConfidential(): bool
  142.     {
  143.         return !empty($this->secret);
  144.     }
  145.     /**
  146.      * @psalm-mutation-free
  147.      */
  148.     public function isPlainTextPkceAllowed(): bool
  149.     {
  150.         return $this->allowPlainTextPkce;
  151.     }
  152.     public function setAllowPlainTextPkce(bool $allowPlainTextPkce): ClientInterface
  153.     {
  154.         $this->allowPlainTextPkce $allowPlainTextPkce;
  155.         return $this;
  156.     }
  157. }