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 is_array;
13
use function sprintf;
14
 
15
/**
16
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
17
 */
18
abstract class TraversableContains extends Constraint
19
{
20
    /**
21
     * @var mixed
22
     */
23
    private $value;
24
 
25
    public function __construct($value)
26
    {
27
        $this->value = $value;
28
    }
29
 
30
    /**
31
     * Returns a string representation of the constraint.
32
     *
33
     * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
34
     */
35
    public function toString(): string
36
    {
37
        return 'contains ' . $this->exporter()->export($this->value);
38
    }
39
 
40
    /**
41
     * Returns the description of the failure.
42
     *
43
     * The beginning of failure messages is "Failed asserting that" in most
44
     * cases. This method should return the second part of that sentence.
45
     *
46
     * @param mixed $other evaluated value or object
47
     *
48
     * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
49
     */
50
    protected function failureDescription($other): string
51
    {
52
        return sprintf(
53
            '%s %s',
54
            is_array($other) ? 'an array' : 'a traversable',
55
            $this->toString()
56
        );
57
    }
58
 
59
    protected function value()
60
    {
61
        return $this->value;
62
    }
63
}