3
* This file is part of PHPUnit.
5
* (c) Sebastian Bergmann <sebastian@phpunit.de>
7
* For the full copyright and license information, please view the LICENSE
8
* file that was distributed with this source code.
12
* Constraint that asserts that the string it is evaluated for matches
13
* a regular expression.
15
* Checks a given value using the Perl Compatible Regular Expression extension
16
* in PHP. The pattern is matched by executing preg_match().
18
* The pattern string passed in the constructor.
21
* @subpackage Framework_Constraint
22
* @author Sebastian Bergmann <sebastian@phpunit.de>
23
* @author Bernhard Schussek <bschussek@2bepublished.at>
24
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
25
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
26
* @link http://www.phpunit.de/
27
* @since Class available since Release 3.0.0
29
class PHPUnit_Framework_Constraint_PCREMatch extends PHPUnit_Framework_Constraint
37
* @param string $pattern
39
public function __construct($pattern)
41
parent::__construct();
42
$this->pattern = $pattern;
46
* Evaluates the constraint for parameter $other. Returns true if the
47
* constraint is met, false otherwise.
49
* @param mixed $other Value or object to evaluate.
52
protected function matches($other)
54
return preg_match($this->pattern, $other) > 0;
58
* Returns a string representation of the constraint.
62
public function toString()
65
'matches PCRE pattern "%s"',