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 ends with a given
16
* @subpackage Framework_Constraint
17
* @author Sebastian Bergmann <sebastian@phpunit.de>
18
* @author Bernhard Schussek <bschussek@2bepublished.at>
19
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
20
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
21
* @link http://www.phpunit.de/
22
* @since Class available since Release 3.4.0
24
class PHPUnit_Framework_Constraint_StringEndsWith extends PHPUnit_Framework_Constraint
32
* @param string $suffix
34
public function __construct($suffix)
36
parent::__construct();
37
$this->suffix = $suffix;
41
* Evaluates the constraint for parameter $other. Returns true if the
42
* constraint is met, false otherwise.
44
* @param mixed $other Value or object to evaluate.
47
protected function matches($other)
49
return substr($other, 0 - strlen($this->suffix)) == $this->suffix;
53
* Returns a string representation of the constraint.
57
public function toString()
59
return 'ends with "' . $this->suffix . '"';