DataSet.php 876 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare(strict_types=1);
  3. namespace Lcobucci\JWT\Token;
  4. use function array_key_exists;
  5. final class DataSet
  6. {
  7. /** @var array<string, mixed> */
  8. private array $data;
  9. private string $encoded;
  10. /** @param mixed[] $data */
  11. public function __construct(array $data, string $encoded)
  12. {
  13. $this->data = $data;
  14. $this->encoded = $encoded;
  15. }
  16. /**
  17. * @param mixed|null $default
  18. *
  19. * @return mixed|null
  20. */
  21. public function get(string $name, $default = null)
  22. {
  23. return $this->data[$name] ?? $default;
  24. }
  25. public function has(string $name): bool
  26. {
  27. return array_key_exists($name, $this->data);
  28. }
  29. /** @return mixed[] */
  30. public function all(): array
  31. {
  32. return $this->data;
  33. }
  34. public function toString(): string
  35. {
  36. return $this->encoded;
  37. }
  38. }