getDefaultCountableTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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