LessThanMatcher::matchNumeric()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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