You are here

public function ArrayCollection::forAll in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php \Doctrine\Common\Collections\ArrayCollection::forAll()

Tests whether the given predicate p holds for all elements of this collection.

Parameters

Closure $p The predicate.:

Return value

boolean TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.

Overrides Collection::forAll

File

vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php, line 301

Class

ArrayCollection
An ArrayCollection is a Collection implementation that wraps a regular PHP array.

Namespace

Doctrine\Common\Collections

Code

public function forAll(Closure $p) {
  foreach ($this->elements as $key => $element) {
    if (!$p($key, $element)) {
      return false;
    }
  }
  return true;
}