TimeMatcherException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 38
ccs 19
cts 19
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tooFastMatcherException() 0 9 1
A tooSlowMatcherException() 0 9 1
A notInRangeMatcherException() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\phpspectime;
6
7
use PhpSpec\Exception\Example\MatcherException;
8
use PhpSpec\Formatter\Presenter\Presenter;
9
10
final class TimeMatcherException
11
{
12 2
    public static function notInRangeMatcherException(Presenter $presenter, $result, $from, $to): MatcherException
13
    {
14 2
        return new MatcherException(
15 2
            sprintf(
16
                "Method call not in the expected timespan.\n" .
17
                "From %s to %s second(s) expected,\n" .
18 2
                'Got %s.',
19 2
                $presenter->presentValue($from),
20 2
                $presenter->presentValue($to),
21 2
                $presenter->presentValue($result)
22
            )
23
        );
24
    }
25
26 2
    public static function tooFastMatcherException(Presenter $presenter, $result, float $expected): MatcherException
27
    {
28 2
        return new MatcherException(
29 2
            sprintf(
30
                "Method call too fast to complete.\n" .
31
                "%s second(s) expected,\n" .
32 2
                'Got %s.',
33 2
                $presenter->presentValue($expected),
34 2
                $presenter->presentValue($result)
35
            )
36
        );
37
    }
38
39 2
    public static function tooSlowMatcherException(Presenter $presenter, $result, float $expected): MatcherException
40
    {
41 2
        return new MatcherException(
42 2
            sprintf(
43
                "Method call too slow to complete.\n" .
44
                "%s second(s) expected,\n" .
45 2
                'Got %s.',
46 2
                $presenter->presentValue($expected),
47 2
                $presenter->presentValue($result)
48
            )
49
        );
50
    }
51
}
52