/websocket/vendor/guzzle/http/Guzzle/Http/AbstractEntityBodyDecorator.php

https://github.com/ivebeenlinuxed/Boiler · PHP · 221 lines · 157 code · 45 blank · 19 comment · 2 complexity · 36d4a68be72393686cdc9e9173adbfd7 MD5 · raw file

  1. <?php
  2. namespace Guzzle\Http;
  3. use Guzzle\Stream\Stream;
  4. /**
  5. * Abstract decorator used to wrap entity bodies
  6. */
  7. class AbstractEntityBodyDecorator implements EntityBodyInterface
  8. {
  9. /** @var EntityBodyInterface Decorated entity body */
  10. protected $body;
  11. /**
  12. * @param EntityBodyInterface $body Entity body to decorate
  13. */
  14. public function __construct(EntityBodyInterface $body)
  15. {
  16. $this->body = $body;
  17. }
  18. public function __toString()
  19. {
  20. return (string) $this->body;
  21. }
  22. /**
  23. * Allow decorators to implement custom methods
  24. *
  25. * @param string $method Missing method name
  26. * @param array $args Method arguments
  27. *
  28. * @return mixed
  29. */
  30. public function __call($method, array $args)
  31. {
  32. return call_user_func_array(array($this->body, $method), $args);
  33. }
  34. public function close()
  35. {
  36. return $this->body->close();
  37. }
  38. public function setRewindFunction($callable)
  39. {
  40. $this->body->setRewindFunction($callable);
  41. return $this;
  42. }
  43. public function rewind()
  44. {
  45. return $this->body->rewind();
  46. }
  47. public function compress($filter = 'zlib.deflate')
  48. {
  49. return $this->body->compress($filter);
  50. }
  51. public function uncompress($filter = 'zlib.inflate')
  52. {
  53. return $this->body->uncompress($filter);
  54. }
  55. public function getContentLength()
  56. {
  57. return $this->getSize();
  58. }
  59. public function getContentType()
  60. {
  61. return $this->body->getContentType();
  62. }
  63. public function getContentMd5($rawOutput = false, $base64Encode = false)
  64. {
  65. $hash = Stream::getHash($this, 'md5', $rawOutput);
  66. return $hash && $base64Encode ? base64_encode($hash) : $hash;
  67. }
  68. public function getContentEncoding()
  69. {
  70. return $this->body->getContentEncoding();
  71. }
  72. public function getMetaData($key = null)
  73. {
  74. return $this->body->getMetaData($key);
  75. }
  76. public function getStream()
  77. {
  78. return $this->body->getStream();
  79. }
  80. public function setStream($stream, $size = 0)
  81. {
  82. $this->body->setStream($stream, $size);
  83. return $this;
  84. }
  85. public function detachStream()
  86. {
  87. $this->body->detachStream();
  88. return $this;
  89. }
  90. public function getWrapper()
  91. {
  92. return $this->body->getWrapper();
  93. }
  94. public function getWrapperData()
  95. {
  96. return $this->body->getWrapperData();
  97. }
  98. public function getStreamType()
  99. {
  100. return $this->body->getStreamType();
  101. }
  102. public function getUri()
  103. {
  104. return $this->body->getUri();
  105. }
  106. public function getSize()
  107. {
  108. return $this->body->getSize();
  109. }
  110. public function isReadable()
  111. {
  112. return $this->body->isReadable();
  113. }
  114. public function isRepeatable()
  115. {
  116. return $this->isSeekable() && $this->isReadable();
  117. }
  118. public function isWritable()
  119. {
  120. return $this->body->isWritable();
  121. }
  122. public function isConsumed()
  123. {
  124. return $this->body->isConsumed();
  125. }
  126. /**
  127. * Alias of isConsumed()
  128. * {@inheritdoc}
  129. */
  130. public function feof()
  131. {
  132. return $this->isConsumed();
  133. }
  134. public function isLocal()
  135. {
  136. return $this->body->isLocal();
  137. }
  138. public function isSeekable()
  139. {
  140. return $this->body->isSeekable();
  141. }
  142. public function setSize($size)
  143. {
  144. $this->body->setSize($size);
  145. return $this;
  146. }
  147. public function seek($offset, $whence = SEEK_SET)
  148. {
  149. return $this->body->seek($offset, $whence);
  150. }
  151. public function read($length)
  152. {
  153. return $this->body->read($length);
  154. }
  155. public function write($string)
  156. {
  157. return $this->body->write($string);
  158. }
  159. public function readLine($maxLength = null)
  160. {
  161. return $this->body->readLine($maxLength);
  162. }
  163. public function ftell()
  164. {
  165. return $this->body->ftell();
  166. }
  167. public function getCustomData($key)
  168. {
  169. return $this->body->getCustomData($key);
  170. }
  171. public function setCustomData($key, $value)
  172. {
  173. $this->body->setCustomData($key, $value);
  174. return $this;
  175. }
  176. }