<?php namespace Hamcrest\Core; /* Copyright (c) 2009 hamcrest.org */ use Hamcrest\Description; use Hamcrest\Matcher; use Hamcrest\TypeSafeDiagnosingMatcher; class Every extends TypeSafeDiagnosingMatcher { private $_matcher; public function __construct(Matcher $matcher) { parent::__construct(self::TYPE_ARRAY); $this->_matcher = $matcher; } protected function matchesSafelyWithDiagnosticDescription($items, Description $mismatchDescription) { foreach ($items as $item) { if (!$this->_matcher->matches($item)) { $mismatchDescription->appendText('an item '); $this->_matcher->describeMismatch($item, $mismatchDescription); return false; } } return true; } public function describeTo(Description $description) { $description->appendText('every item is ')->appendDescriptionOf($this->_matcher); } /** * @param Matcher $itemMatcher * A matcher to apply to every element in an array. * * @return \Hamcrest\Core\Every * Evaluates to TRUE for a collection in which every item matches $itemMatcher * * @factory */ public static function everyItem(Matcher $itemMatcher) { return new self($itemMatcher); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
AllOf.php | File | 1.42 KB | 0644 |
|
AnyOf.php | File | 1.23 KB | 0644 |
|
CombinableMatcher.php | File | 1.74 KB | 0644 |
|
DescribedAs.php | File | 1.81 KB | 0644 |
|
Every.php | File | 1.31 KB | 0644 |
|
HasToString.php | File | 1.24 KB | 0644 |
|
Is.php | File | 1.32 KB | 0644 |
|
IsAnything.php | File | 875 B | 0644 |
|
IsCollectionContaining.php | File | 2.11 KB | 0644 |
|
IsEqual.php | File | 835 B | 0644 |
|
IsIdentical.php | File | 708 B | 0644 |
|
IsInstanceOf.php | File | 1.66 KB | 0644 |
|
IsNot.php | File | 826 B | 0644 |
|
IsNull.php | File | 976 B | 0644 |
|
IsSame.php | File | 1.07 KB | 0644 |
|
IsTypeOf.php | File | 1.64 KB | 0644 |
|
Set.php | File | 2.35 KB | 0644 |
|
ShortcutCombination.php | File | 920 B | 0644 |
|