GreaterThanMatcher::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
 * GreaterThanMatcher determines if the actual value is greater than the expected value.
10
 *
11
 * @package Peridot\Leo\Matcher
12
 */
13
class GreaterThanMatcher 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 above {{expected}}',
24
            'negated' => 'Expected {{actual}} to be at most {{expected}}',
25
        ]);
26
    }
27
28
    /**
29
     * @return ArrayTemplate
30
     */
31
    public function getDefaultCountableTemplate()
32
    {
33
        $count = $this->getCount();
34
35
        return new ArrayTemplate([
36
            'default' => "Expected {{actual}} to have a length above {{expected}} but got $count",
37
            'negated' => 'Expected {{actual}} to not have a length above {{expected}}',
38
        ]);
39
    }
40
41
    /**
42
     * Match that actual number is greater 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