You are here

protected function PHPUnit_Framework_Constraint_ArrayHasKey::matches in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/Constraint/ArrayHasKey.php \PHPUnit_Framework_Constraint_ArrayHasKey::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/ArrayHasKey.php, line 44

Class

PHPUnit_Framework_Constraint_ArrayHasKey
Constraint that asserts that the array it is evaluated for has a given key.

Code

protected function matches($other) {
  if (is_array($other)) {
    return array_key_exists($this->key, $other);
  }
  if ($other instanceof ArrayAccess) {
    return $other
      ->offsetExists($this->key);
  }
  return false;
}