Completed
Push — master ( cf562f...62fcb6 )
by Simon
02:58
created

ExtraMatchers::register()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

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