contents = $contents; } public function getStream(): StreamInterface { $resource = fopen('php://temp', 'r+'); fwrite($resource, $this->getString()); rewind($resource); return new Stream($resource); } public function getString(): string { return $this->contents; } public function getLength(): int { return strlen($this->contents); } public static function createFromString(string $contents): ContentsString { $obj = new self($contents); return $obj; } }