LessThanMatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultTemplate() 0 7 1
A getDefaultCountableTemplate() 0 9 1
A matchNumeric() 0 4 1
1
<?php
2
3
namespace Peridot\Leo\Matcher;
4
5
use Peridot\Leo\Matcher\Template\ArrayTemplate;
6
use Peridot\Leo\Matcher\Template\TemplateInterface;
7
8
/**
9
 * LessThanMatcher determines if an actual value is less than the expected value.
10
 *
11
 * @package Peridot\Leo\Matcher
12
 */
13
class LessThanMatcher extends CountableMatcher
14
{
15
    /**
16
     * {@inheritdoc}
17
     *
18
     * @return TemplateInterface
19
     */
20
    public function getDefaultTemplate()
21
    {
22
        return new ArrayTemplate([
23
            'default' => 'Expected {{actual}} to be below {{expected}}',
24
            'negated' => 'Expected {{actual}} to be at least {{expected}}',
25
        ]);
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     *
31
     * @return ArrayTemplate
32
     */
33
    public function getDefaultCountableTemplate()
34
    {
35
        $count = $this->getCount();
36
37
        return new ArrayTemplate([
38
            'default' => "Expected {{actual}} to have a length below {{expected}} but got $count",
39
            'negated' => 'Expected {{actual}} to not have a length below {{expected}}',
40
        ]);
41
    }
42
43
    /**
44
     * Match that actual number is less than the expected value.
45
     *
46
     * @param $number
47
     * @return bool
48
     */
49
    protected function matchNumeric($number)
50
    {
51
        return $number < $this->expected;
52
    }
53
}
54