Chris@0: stream = $stream; Chris@0: $this->maxLength = $maxLength; Chris@0: } Chris@0: Chris@0: public function write($string) Chris@0: { Chris@0: $diff = $this->maxLength - $this->stream->getSize(); Chris@0: Chris@0: // Begin returning 0 when the underlying stream is too large. Chris@0: if ($diff <= 0) { Chris@0: return 0; Chris@0: } Chris@0: Chris@0: // Write the stream or a subset of the stream if needed. Chris@0: if (strlen($string) < $diff) { Chris@0: return $this->stream->write($string); Chris@0: } Chris@0: Chris@0: return $this->stream->write(substr($string, 0, $diff)); Chris@0: } Chris@0: }