10 trait StreamDecoratorTrait
15 public function __construct(StreamInterface $stream)
17 $this->stream = $stream;
28 public function __get($name)
30 if ($name ==
'stream') {
31 $this->stream = $this->createStream();
35 throw new \UnexpectedValueException(
"$name not found on class");
45 }
catch (\Exception $e) {
47 trigger_error(
'StreamDecorator::__toString exception: '
48 . (
string) $e, E_USER_ERROR);
66 public function __call($method, array $args)
68 $result = call_user_func_array([$this->stream, $method], $args);
71 return $result === $this->stream ? $this : $result;
74 public function close()
76 $this->stream->close();
81 return $this->stream->getMetadata($key);
86 return $this->stream->detach();
91 return $this->stream->getSize();
96 return $this->stream->eof();
99 public function tell()
101 return $this->stream->tell();
106 return $this->stream->isReadable();
111 return $this->stream->isWritable();
116 return $this->stream->isSeekable();
124 public function seek($offset, $whence = SEEK_SET)
126 $this->stream->seek($offset, $whence);
129 public function read($length)
131 return $this->stream->read($length);
134 public function write($string)
136 return $this->stream->write($string);
145 protected function createStream()
147 throw new \BadMethodCallException(
'Not implemented');