BinaryValue.php 743 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Aws\DynamoDb;
  3. use GuzzleHttp\Psr7;
  4. /**
  5. * Special object to represent a DynamoDB binary (B) value.
  6. */
  7. class BinaryValue implements \JsonSerializable
  8. {
  9. /** @var string Binary value. */
  10. private $value;
  11. /**
  12. * @param mixed $value A binary value compatible with Guzzle streams.
  13. *
  14. * @see GuzzleHttp\Stream\Stream::factory
  15. */
  16. public function __construct($value)
  17. {
  18. if (!is_string($value)) {
  19. $value = Psr7\Utils::streamFor($value);
  20. }
  21. $this->value = (string) $value;
  22. }
  23. #[\ReturnTypeWillChange]
  24. public function jsonSerialize()
  25. {
  26. return $this->value;
  27. }
  28. public function __toString()
  29. {
  30. return $this->value;
  31. }
  32. }