Completed
Pull Request — master (#2)
by Abdul Malik
12:36
created

ToEqualOneOf   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B match() 0 14 6
A description() 0 4 1
1
<?php
2
namespace Kahlan\Extra\Matcher;
3
4
class ToEqualOneOf
5
{
6
    /**
7
     * Checks that `$expected` has value of `$actual` ( non-identic ).
8
     *
9
     * @param mixed $actual   The actual value
10
     * @param mixed $expected The expected value
11
     *
12
     * @return bool
13
     */
14
    public static function match($actual, $expected)
15
    {
16
        if (is_string($expected)) {
17
            return strpos($expected, $actual) !== false;
18
        } elseif (is_array($expected) || $expected instanceof Traversable) {
0 ignored issues
show
Bug introduced by
The class Kahlan\Extra\Matcher\Traversable does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
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