protected function consumeStream($callback)
    {
        // Load from stream
        $stream = $this->getStream();
        if (!$stream) {
            return null;
        }

        // Check if stream must be rewound
        if ($this->consumed) {
            if (!$this->isSeekable()) {
                throw new BadMethodCallException(
                    "Unseekable stream has already been consumed"
                );
            }
            rewind($stream);
        }

        // Consume
        $this->consumed = true;
        return $callback($stream);
    }