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

getDefaultCountableTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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