isCallable() public static method

Assert that the value is callable.
public static isCallable ( mixed $value, string $message = null, null $propertyPath = null ) : void
$value mixed Variable to check for a callable.
$message string Exception message to show if value is not a callable.
$propertyPath null
return void
Esempio n. 1
0
 /**
  * @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;
 }
Esempio n. 2
0
 /**
  * @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;
 }
Esempio n. 3
0
 /**
  * @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;
 }
Esempio n. 4
0
 /**
  * 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;
 }