- \PHPUnit_Framework_Constraint
- \PHPUnit_Framework_Constraint_PCREMatch
class (none) \ PHPUnit_Framework_Constraint_PCREMatch
- All implemented interfaces:
- Countable, PHPUnit_Framework_SelfDescribing
- All known direct subclasses:
- PHPUnit_Framework_Constraint_StringMatches
Constraint that asserts that the string it is evaluated for matches a regular expression.
Checks a given value using the Perl Compatible Regular Expression extension in PHP. The pattern is matched by executing preg_match().
The pattern string passed in the constructor.
Method Summary
| Name | Description |
|---|---|
| __construct($pattern) | |
| matches($other) | Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise. |
| toString() | Returns a string representation of the constraint. |
Inherited Method Summary
| Name | Description |
|---|---|
| additionalFailureDescription($other) | Return additional failure description where needed (from PHPUnit_Framework_Constraint) |
| count() | Counts the number of constraint elements. (from PHPUnit_Framework_Constraint) |
| evaluate($other, $description = "", $returnResult = false) | Evaluates the constraint for parameter $other (from PHPUnit_Framework_Constraint) |
| fail($other, $description, ComparisonFailure $comparisonFailure = null) | Throws an exception for the given compared value and test description (from PHPUnit_Framework_Constraint) |
| failureDescription($other) | Returns the description of the failure (from PHPUnit_Framework_Constraint) |
public function __construct($pattern)
- Overrides:
- __construct()
- Parameters:
string- $pattern
protected function matches($other)
Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.
This method can be overridden to implement the evaluation algorithm. (from matches)
- Overrides:
- matches($other)
- Parameters:
mixed- $other Value or object to evaluate.- Returns:
- bool
public function toString()
Returns a string representation of the constraint.
- Returns:
- string