/** * {@inheritdoc} */ public function __toString() { try { return Util::copyToString($this); } catch (Exception $e) { return ''; } }
public function testCopiesToStringStopsWhenReadFails() { $body = 'foobaz'; $stream = fopen('php://temp', 'r+'); fwrite($stream, $body); fseek($stream, 0); $s1 = new Stream($stream); $s1 = FnStream::decorate($s1, ['read' => function () { return ''; }]); $result = Util::copyToString($s1); $this->assertEquals('', $result); }
/** * {@inheritdoc} */ public function getContents() { return Util::copyToString($this); }