string; } public function __toString(): string { return $this->string; } /** * Creates an instance an existing object. * * @param Stringable|string $string Object to cast to a string. * @return StringContent Instance representing the provided object. */ public static function fromObject(Stringable|string $string): StringContent { return new StringContent((string)$string); } /** * Creates an instance from a file. * * @param string $path Path to the file. * @return StringContent Instance representing the provided path. */ public static function fromFile(string $path): StringContent { return new StringContent(file_get_contents($path)); } /** * Creates an instance from the raw request body. * * @return StringContent Instance representing the request body. */ public static function fromRequest(): StringContent { return self::fromFile('php://input'); } }