body = $body; } /** * @return string */ public function __toString(): string { return $this->body; } /** * */ public function close(): void { $this->detach(); } /** * */ public function detach(): void { $this->body = ''; $this->size = 0; $this->writable = false; } /** * @return int */ public function getSize(): int { if ($this->size == 0) { $this->size = strlen($this->body); } return $this->size; } /** * @return int */ public function tell(): int { return $this->offset; } /** * @return bool */ public function eof(): bool { return true; } /** * @return bool */ public function isSeekable(): bool { return $this->offset == 0; } /** * @param int $offset * @param int $whence */ public function seek($offset, $whence = SEEK_SET) { $this->offset = $offset; } /** * */ public function rewind(): void { $this->offset = 0; } /** * @return bool */ public function isWritable(): bool { return $this->writable; } /** * @param string $string * @return int */ public function write($string): int { // TODO: Implement write() method. $this->body .= $string; $this->size = strlen($this->body); return $this->size; } /** * @return bool */ public function isReadable(): bool { return true; } /** * @param int $length * @return string */ public function read($length): string { // TODO: Implement read() method. return substr($this->body, 0, $length); } /** * @return string */ public function getContents(): string { return $this->body; } /** * @param null $key * @return mixed */ public function getMetadata($key = null): mixed { throw new \BadMethodCallException('Not Accomplish Method.'); } }