CsrfToken.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /**
  21. * @param string $id The token ID
  22. * @param string $value The actual token value
  23. */
  24. public function __construct($id, $value)
  25. {
  26. $this->id = (string) $id;
  27. $this->value = (string) $value;
  28. }
  29. /**
  30. * Returns the ID of the CSRF token.
  31. *
  32. * @return string The token ID
  33. */
  34. public function getId()
  35. {
  36. return $this->id;
  37. }
  38. /**
  39. * Returns the value of the CSRF token.
  40. *
  41. * @return string The token value
  42. */
  43. public function getValue()
  44. {
  45. return $this->value;
  46. }
  47. /**
  48. * Returns the value of the CSRF token.
  49. *
  50. * @return string The token value
  51. */
  52. public function __toString()
  53. {
  54. return $this->value;
  55. }
  56. }