DataChunk.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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\HttpClient\Chunk;
  11. use Symfony\Contracts\HttpClient\ChunkInterface;
  12. /**
  13. * @author Nicolas Grekas <p@tchwork.com>
  14. *
  15. * @internal
  16. */
  17. class DataChunk implements ChunkInterface
  18. {
  19. private $offset = 0;
  20. private $content = '';
  21. public function __construct(int $offset = 0, string $content = '')
  22. {
  23. $this->offset = $offset;
  24. $this->content = $content;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function isTimeout(): bool
  30. {
  31. return false;
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function isFirst(): bool
  37. {
  38. return false;
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function isLast(): bool
  44. {
  45. return false;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public function getInformationalStatus(): ?array
  51. {
  52. return null;
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function getContent(): string
  58. {
  59. return $this->content;
  60. }
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public function getOffset(): int
  65. {
  66. return $this->offset;
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public function getError(): ?string
  72. {
  73. return null;
  74. }
  75. }