Completed
Pull Request — master (#23)
by Erin
03:28
created

LessThanMatcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

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