ToBeOneOf   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

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 ToBeOneOf
7
{
8
    /**
9
     * Checks that `$expected` has value of `$actual` ( strict ).
10
     *
11
     * @param  mixed   $actual   The actual value.
12
     * @param  mixed   $expected The expected value.
13
     * @return boolean
14
     */
15
    public static function match($actual, $expected)
16
    {
17
        if (is_array($expected) || $expected instanceof Traversable) {
18
            foreach ($expected as $key => $value) {
19
                if ($value === $actual) {
20 3
                    return true;
21
                }
22
            }
23
        }
24
25 2
        return false;
26
    }
27
28
    /**
29
     * Returns the description message.
30
     *
31
     * @return string The description message.
32
     */
33
    public static function description()
34
    {
35 4
        return "be part of the expected values.";
36
    }
37
}
38