/** * @inheritDoc */ public function enable(\Closure $requestCallback) { Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); self::$requestCallback = $requestCallback; stream_wrapper_unregister('http'); stream_wrapper_register('http', __CLASS__, STREAM_IS_URL); stream_wrapper_unregister('https'); stream_wrapper_register('https', __CLASS__, STREAM_IS_URL); $this->status = self::ENABLED; }
/** * @inheritDoc */ public function enable(\Closure $requestCallback) { Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); if (static::$status == self::ENABLED) { return; } $this->codeTransformer->register(); $this->processor->appendCodeTransformer($this->codeTransformer); $this->processor->intercept(); self::$requestCallback = $requestCallback; static::$status = self::ENABLED; }
/** * @inheritDoc */ public function enable(\Closure $requestCallback) { self::$codeTransformer->register(); self::$processor->appendCodeTransformer(self::$codeTransformer); self::$processor->intercept(); Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); self::$requestCallback = $requestCallback; stream_wrapper_unregister('http'); stream_wrapper_register('http', __CLASS__, STREAM_IS_URL); stream_wrapper_unregister('https'); stream_wrapper_register('https', __CLASS__, STREAM_IS_URL); $this->status = self::ENABLED; }
/** * Adds a new RequestMatcher callback. * * @param string $name Name of the RequestMatcher. * @param callable $callback A callback taking two Request objects as parameters and returns true if those match. * * @return Configuration * @throws VCRException If specified parameters are invalid. */ public function addRequestMatcher($name, $callback) { Assertion::minLength($name, 1, "A request matchers name must be at least one character long. Found '{$name}'"); Assertion::isCallable($callback, "Request matcher '{$name}' is not callable."); $this->availableRequestMatchers[$name] = $callback; return $this; }