Extension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 43
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 29
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 43
ccs 26
cts 26
cp 1
crap 1
rs 9.456
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\phpspectime;
6
7
use loophp\nanobench\BenchmarkFactory;
8
use loophp\nanobench\Time\TimeUnit;
9
use loophp\phpspectime\Matcher\TakeInBetweenMatcher;
10
use loophp\phpspectime\Matcher\TakeLessThanMatcher;
11
use loophp\phpspectime\Matcher\TakeMoreThanMatcher;
12
use PhpSpec\Extension as ExtensionInterface;
13
use PhpSpec\ServiceContainer;
14
use PhpSpec\ServiceContainer\IndexedServiceContainer;
15
16
final class Extension implements ExtensionInterface
17
{
18
    /**
19
     * @return void
20
     */
21 1
    public function load(ServiceContainer $container, array $params)
22
    {
23
        $params += [
24 1
            'timeunit' => TimeUnit::SECOND,
25
        ];
26
27 1
        $container->define(
28 1
            'matchers.takeMoreThan',
29
            static function (IndexedServiceContainer $c) use ($params) {
30 1
                return new TakeMoreThanMatcher(
31 1
                    $c->get('unwrapper'),
32 1
                    $c->get('formatter.presenter'),
33 1
                    new BenchmarkFactory(),
34
                    $params
35
                );
36 1
            },
37 1
            ['matchers']
38
        );
39
40 1
        $container->define(
41 1
            'matchers.takeLessThan',
42
            static function (IndexedServiceContainer $c) use ($params) {
43 1
                return new TakeLessThanMatcher(
44 1
                    $c->get('unwrapper'),
45 1
                    $c->get('formatter.presenter'),
46 1
                    new BenchmarkFactory(),
47
                    $params
48
                );
49 1
            },
50 1
            ['matchers']
51
        );
52
53 1
        $container->define(
54 1
            'matchers.takeInBetween',
55
            static function (IndexedServiceContainer $c) use ($params) {
56 1
                return new TakeInBetweenMatcher(
57 1
                    $c->get('unwrapper'),
58 1
                    $c->get('formatter.presenter'),
59 1
                    new BenchmarkFactory(),
60
                    $params
61
                );
62 1
            },
63 1
            ['matchers']
64
        );
65 1
    }
66
}
67