CsrfToken.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\Csrf;
  11. /**
  12. * A CSRF token.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. class CsrfToken
  17. {
  18. private $id;
  19. private $value;
  20. public function __construct(string $id, ?string $value)
  21. {
  22. $this->id = $id;
  23. $this->value = $value ?? '';
  24. }
  25. /**
  26. * Returns the ID of the CSRF token.
  27. *
  28. * @return string The token ID
  29. */
  30. public function getId()
  31. {
  32. return $this->id;
  33. }
  34. /**
  35. * Returns the value of the CSRF token.
  36. *
  37. * @return string The token value
  38. */
  39. public function getValue()
  40. {
  41. return $this->value;
  42. }
  43. /**
  44. * Returns the value of the CSRF token.
  45. *
  46. * @return string The token value
  47. */
  48. public function __toString()
  49. {
  50. return $this->value;
  51. }
  52. }