public function __construct($stream, $size = null) { if (!is_resource($stream)) { throw new InvalidArgumentException('Stream must be a resource'); } $this->size = $size; $this->stream = $stream; }