Completed
Push — master ( 21d74d...7c384e )
by Abdul Malik
02:51 queued 01:01
created

ToEqualOneOf::match()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 2
cts 2
cp 1
rs 8.8571
cc 5
eloc 6
nc 3
nop 2
crap 5
1
<?php
2
namespace Kahlan\Extra\Matcher;
3
4
use Traversable;
5
6
class ToEqualOneOf
7
{
8
    /**
9
     * Checks that `$expected` has value of `$actual` ( loose ).
10
     *
11
     * @param mixed $actual   The actual value
12
     * @param mixed $expected The expected value
13
     *
14
     * @return bool
15
     */
16
    public static function match($actual, $expected)
17
    {
18
        if (is_array($expected) || $expected instanceof Traversable) {
19
            foreach ($expected as $key => $value) {
20
                if ($value == $actual) {
21 2
                    return true;
22
                }
23
            }
24
        }
25
26 1
        return false;
27
    }
28
29
    /**
30
     * Returns the description message.
31
     *
32
     * @return string The description message
33
     */
34
    public static function description()
35
    {
36 3
        return 'be part of the expected values.';
37
    }
38
}
39