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

ToEqualOneOf   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 33
ccs 3
cts 3
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A description() 0 4 1
B match() 0 12 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