Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
namespace Hamcrest\Core;
3
 
4
/*
5
 Copyright (c) 2009 hamcrest.org
6
 */
7
 
8
use Hamcrest\BaseMatcher;
9
use Hamcrest\Description;
10
use Hamcrest\Util;
11
 
12
abstract class ShortcutCombination extends BaseMatcher
13
{
14
 
15
    /**
16
     * @var array<\Hamcrest\Matcher>
17
     */
18
    private $_matchers;
19
 
20
    public function __construct(array $matchers)
21
    {
22
        Util::checkAllAreMatchers($matchers);
23
 
24
        $this->_matchers = $matchers;
25
    }
26
 
27
    protected function matchesWithShortcut($item, $shortcut)
28
    {
29
        /** @var $matcher \Hamcrest\Matcher */
30
        foreach ($this->_matchers as $matcher) {
31
            if ($matcher->matches($item) == $shortcut) {
32
                return $shortcut;
33
            }
34
        }
35
 
36
        return !$shortcut;
37
    }
38
 
39
    public function describeToWithOperator(Description $description, $operator)
40
    {
41
        $description->appendList('(', ' ' . $operator . ' ', ')', $this->_matchers);
42
    }
43
}