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 SplObjectStorage;
13
 
14
/**
15
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
16
 */
17
final class TraversableContainsEqual extends TraversableContains
18
{
19
    /**
20
     * Evaluates the constraint for parameter $other. Returns true if the
21
     * constraint is met, false otherwise.
22
     *
23
     * @param mixed $other value or object to evaluate
24
     */
25
    protected function matches($other): bool
26
    {
27
        if ($other instanceof SplObjectStorage) {
28
            return $other->contains($this->value());
29
        }
30
 
31
        foreach ($other as $element) {
32
            /* @noinspection TypeUnsafeComparisonInspection */
33
            if ($this->value() == $element) {
34
                return true;
35
            }
36
        }
37
 
38
        return false;
39
    }
40
}