You are here

protected function PHPUnit_Framework_Constraint_TraversableContains::matches in Zircon Profile 8

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

Class

PHPUnit_Framework_Constraint_TraversableContains
Constraint that asserts that the Traversable it is applied to contains a given value.

Code

protected function matches($other) {
  if ($other instanceof SplObjectStorage) {
    return $other
      ->contains($this->value);
  }
  if (is_object($this->value)) {
    foreach ($other as $element) {
      if ($this->checkForObjectIdentity && $element === $this->value || !$this->checkForObjectIdentity && $element == $this->value) {
        return true;
      }
    }
  }
  else {
    foreach ($other as $element) {
      if ($this->checkForNonObjectIdentity && $element === $this->value || !$this->checkForNonObjectIdentity && $element == $this->value) {
        return true;
      }
    }
  }
  return false;
}