PersistentToken.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Core\Authentication\RememberMe;
  11. /**
  12. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  13. *
  14. * @internal
  15. */
  16. final class PersistentToken implements PersistentTokenInterface
  17. {
  18. private $class;
  19. private $username;
  20. private $series;
  21. private $tokenValue;
  22. private $lastUsed;
  23. public function __construct(string $class, string $username, string $series, string $tokenValue, \DateTime $lastUsed)
  24. {
  25. if (empty($class)) {
  26. throw new \InvalidArgumentException('$class must not be empty.');
  27. }
  28. if ('' === $username) {
  29. throw new \InvalidArgumentException('$username must not be empty.');
  30. }
  31. if (empty($series)) {
  32. throw new \InvalidArgumentException('$series must not be empty.');
  33. }
  34. if (empty($tokenValue)) {
  35. throw new \InvalidArgumentException('$tokenValue must not be empty.');
  36. }
  37. $this->class = $class;
  38. $this->username = $username;
  39. $this->series = $series;
  40. $this->tokenValue = $tokenValue;
  41. $this->lastUsed = $lastUsed;
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getClass(): string
  47. {
  48. return $this->class;
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function getUsername(): string
  54. {
  55. return $this->username;
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function getSeries(): string
  61. {
  62. return $this->series;
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function getTokenValue(): string
  68. {
  69. return $this->tokenValue;
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. public function getLastUsed(): \DateTime
  75. {
  76. return $this->lastUsed;
  77. }
  78. }