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
use Hamcrest\Description;
8
use Hamcrest\Util;
9
 
10
/**
11
 * Calculates the logical disjunction of multiple matchers. Evaluation is
12
 * shortcut, so subsequent matchers are not called if an earlier matcher
13
 * returns <code>true</code>.
14
 */
15
class AnyOf extends ShortcutCombination
16
{
17
 
18
    public function __construct(array $matchers)
19
    {
20
        parent::__construct($matchers);
21
    }
22
 
23
    public function matches($item)
24
    {
25
        return $this->matchesWithShortcut($item, true);
26
    }
27
 
28
    public function describeTo(Description $description)
29
    {
30
        $this->describeToWithOperator($description, 'or');
31
    }
32
 
33
    /**
34
     * Evaluates to true if ANY of the passed in matchers evaluate to true.
35
     *
36
     * @factory ...
37
     */
38
    public static function anyOf(/* args... */)
39
    {
40
        $args = func_get_args();
41
 
42
        return new self(Util::createMatcherArray($args));
43
    }
44
 
45
    /**
46
     * Evaluates to false if ANY of the passed in matchers evaluate to true.
47
     *
48
     * @factory ...
49
     */
50
    public static function noneOf(/* args... */)
51
    {
52
        $args = func_get_args();
53
 
54
        return IsNot::not(
55
            new self(Util::createMatcherArray($args))
56
        );
57
    }
58
}