LessThanOrEqualMatcher::getDefaultTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
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
 * LessThanOrEqualMatcher determines if an actual value is less than or equal to the expected value.
10
 *
11
 * @package Peridot\Leo\Matcher
12
 */
13
class LessThanOrEqualMatcher extends CountableMatcher
14
{
15
    /**
16
     * Match that the actual number is less than or equal
17
     * to the expected value.
18
     *
19
     * @param $number
20
     * @return bool
21
     */
22
    protected function matchNumeric($number)
23
    {
24
        return $number <= $this->expected;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     *
30
     * @return TemplateInterface
31
     */
32
    public function getDefaultTemplate()
33
    {
34
        return new ArrayTemplate([
35
            'default' => 'Expected {{actual}} to be at most {{expected}}',
36
            'negated' => 'Expected {{actual}} to be above {{expected}}',
37
        ]);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     *
43
     * @return TemplateInterface
44
     */
45
    public function getDefaultCountableTemplate()
46
    {
47
        $count = $this->getCount();
48
49
        return new ArrayTemplate([
50
            'default' => "Expected {{actual}} to have a length at most {{expected}} but got $count",
51
            'negated' => 'Expected {{actual}} to have a length above {{expected}}',
52
        ]);
53
    }
54
}
55