Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PHPUnit\Framework\Constraint;
11
 
12
use function strlen;
13
use function substr;
14
 
15
/**
16
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
17
 */
18
final class StringEndsWith extends Constraint
19
{
20
    /**
21
     * @var string
22
     */
23
    private $suffix;
24
 
25
    public function __construct(string $suffix)
26
    {
27
        $this->suffix = $suffix;
28
    }
29
 
30
    /**
31
     * Returns a string representation of the constraint.
32
     */
33
    public function toString(): string
34
    {
35
        return 'ends with "' . $this->suffix . '"';
36
    }
37
 
38
    /**
39
     * Evaluates the constraint for parameter $other. Returns true if the
40
     * constraint is met, false otherwise.
41
     *
42
     * @param mixed $other value or object to evaluate
43
     */
44
    protected function matches($other): bool
45
    {
46
        return substr($other, 0 - strlen($this->suffix)) === $this->suffix;
47
    }
48
}