<?php namespace Hamcrest\Core; /* Copyright (c) 2009 hamcrest.org */ use Hamcrest\Description; use Hamcrest\DiagnosingMatcher; use Hamcrest\Util; /** * Calculates the logical conjunction of multiple matchers. Evaluation is * shortcut, so subsequent matchers are not called if an earlier matcher * returns <code>false</code>. */ class AllOf extends DiagnosingMatcher { private $_matchers; public function __construct(array $matchers) { Util::checkAllAreMatchers($matchers); $this->_matchers = $matchers; } public function matchesWithDiagnosticDescription($item, Description $mismatchDescription) { /** @var $matcher \Hamcrest\Matcher */ foreach ($this->_matchers as $matcher) { if (!$matcher->matches($item)) { $mismatchDescription->appendDescriptionOf($matcher)->appendText(' '); $matcher->describeMismatch($item, $mismatchDescription); return false; } } return true; } public function describeTo(Description $description) { $description->appendList('(', ' and ', ')', $this->_matchers); } /** * Evaluates to true only if ALL of the passed in matchers evaluate to true. * * @factory ... */ public static function allOf(/* args... */) { $args = func_get_args(); return new self(Util::createMatcherArray($args)); } }
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 |
|