ExtraMatchers::register()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 10
nc 6
nop 1
crap 4
1
<?php
2
namespace Kahlan\Extra\Matcher;
3
4
use Exception;
5
use Kahlan\Matcher;
6
7
class ExtraMatchers
8
{
9
    public static function register($matchers = [])
10
    {
11
        $map = [
12
            'toBeOneOf'    => 'Kahlan\Extra\Matcher\ToBeOneOf',
13
            'toEqualOneOf' => 'Kahlan\Extra\Matcher\ToEqualOneOf',
14
            'toImplement'  => 'Kahlan\Matcher\ToBeAnInstanceOf'
15 3
        ];
16 3
        $matchers = $matchers ?: array_keys($map);
17
18
        foreach ($matchers as $name) {
19
            if (!isset($map[$name])) {
20 1
                throw new Exception("Unexisting matcher `{$name}` can't register it.");
21
            }
22 2
            Matcher::register($name, $map[$name]);
23
        }
24
    }
25
}
26