public function setContext($context, array $options = array())
    {
        if (!isset($context)) {
            $context = stream_context_create((array) $context, $options);
        }

        if (!is_resource($context)) {
            throw new UnexpectedValueException('Stream context is not a valid resource');
        }

        $this->context = $context;
        return $this;
    }