1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 10:33:18 +01:00

Adding close() method to stream objects

This commit is contained in:
Michael Dowling 2013-03-03 21:25:55 -08:00
parent d9c2824046
commit 38cd929fc8
2 changed files with 18 additions and 3 deletions

View File

@ -70,9 +70,7 @@ class Stream implements StreamInterface
*/
public function __destruct()
{
if (is_resource($this->stream)) {
fclose($this->stream);
}
$this->close();
}
/**
@ -91,6 +89,18 @@ class Stream implements StreamInterface
return $body;
}
/**
* {@inheritdoc}
*/
public function close()
{
if (is_resource($this->stream)) {
fclose($this->stream);
}
$this->cache[self::IS_READABLE] = false;
$this->cache[self::IS_WRITABLE] = false;
}
/**
* Calculate a hash of a Stream
*

View File

@ -14,6 +14,11 @@ interface StreamInterface
*/
public function __toString();
/**
* Close the underlying stream
*/
public function close();
/**
* Get stream metadata
*