Completed
Pull Request — master (#2)
by Abdul Malik
34:41 queued 20:25
created

ToEqualOneOf   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

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
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` ( non-identic ).
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
                    return true;
22
                }
23
            }
24
        }
25
26
        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
        return 'be part of the expected values.';
37
    }
38
}
39