You are here

protected function PHPUnit_Framework_Constraint_IsType::matches in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/Constraint/IsType.php \PHPUnit_Framework_Constraint_IsType::matches()

Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.

Parameters

mixed $other Value or object to evaluate.:

Return value

bool

Overrides PHPUnit_Framework_Constraint::matches

File

vendor/phpunit/phpunit/src/Framework/Constraint/IsType.php, line 87

Class

PHPUnit_Framework_Constraint_IsType
Constraint that asserts that the value it is evaluated for is of a specified type.

Code

protected function matches($other) {
  switch ($this->type) {
    case 'numeric':
      return is_numeric($other);
    case 'integer':
    case 'int':
      return is_integer($other);
    case 'double':
    case 'float':
    case 'real':
      return is_float($other);
    case 'string':
      return is_string($other);
    case 'boolean':
    case 'bool':
      return is_bool($other);
    case 'null':
      return is_null($other);
    case 'array':
      return is_array($other);
    case 'object':
      return is_object($other);
    case 'resource':
      return is_resource($other) || is_string(@get_resource_type($other));
    case 'scalar':
      return is_scalar($other);
    case 'callable':
      return is_callable($other);
  }
}