TakeMoreThanMatcher   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 34
ccs 12
cts 12
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A verifyNegative() 0 12 2
A verifyPositive() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\phpspectime\Matcher;
6
7
use loophp\phpspectime\TimeMatcherException;
8
9
final class TakeMoreThanMatcher extends AbstractTakeThanMatcher
10
{
11
    protected $keywords = [
12
        'takeMoreThan',
13
        'lastMoreThan',
14
    ];
15
16 2
    public function verifyNegative(callable $callable, array $arguments, float $timeInSeconds): bool
17
    {
18 2
        $elapsedTime = $this->bench($callable, $arguments);
19
20 2
        if (false === $timeInSeconds <= $elapsedTime) {
21 1
            return true;
22
        }
23
24 1
        throw TimeMatcherException::tooSlowMatcherException(
25 1
            $this->presenter,
26
            $elapsedTime,
27
            $timeInSeconds
28
        );
29
    }
30
31 2
    public function verifyPositive(callable $callable, array $arguments, float $timeInSeconds): bool
32
    {
33 2
        $elapsedTime = $this->bench($callable, $arguments);
34
35 2
        if (false === $timeInSeconds > $elapsedTime) {
36 1
            return true;
37
        }
38
39 1
        throw TimeMatcherException::tooFastMatcherException(
40 1
            $this->presenter,
41
            $elapsedTime,
42
            $timeInSeconds
43
        );
44
    }
45
}
46