* Matcher implementations should NOT directly implement this interface. * Instead, extend the {@link Hamcrest\BaseMatcher} abstract class, * which will ensure that the Matcher API can grow to support * new features and remain compatible with all Matcher implementations. *
* For easy access to common Matcher implementations, use the static factory * methods in {@link Hamcrest\CoreMatchers}. * * @see Hamcrest\CoreMatchers * @see Hamcrest\BaseMatcher */ interface Matcher extends SelfDescribing { /** * Evaluates the matcher for argument $item. * * @param mixed $item the object against which the matcher is evaluated. * * @return booleantrue
if $item matches,
* otherwise false
.
*
* @see Hamcrest\BaseMatcher
*/
public function matches($item);
/**
* Generate a description of why the matcher has not accepted the item.
* The description will be part of a larger description of why a matching
* failed, so it should be concise.
* This method assumes that matches($item)
is false, but
* will not check this.
*
* @param mixed $item The item that the Matcher has rejected.
* @param Description $description
* @return
*/
public function describeMismatch($item, Description $description);
}