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
 * GreaterThanOrEqualMatcher matches that the actual value is greater than or equal
9
 * to the expected value.
10
 *
11
 * @package Peridot\Leo\Matcher
12
 */
13
class GreaterThanOrEqualMatcher extends CountableMatcher
14
{
15
    /**
16
     * Match that the actual number is greater 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
     * Return a default template if none was set.
29
     *
30
     * @return TemplateInterface
31
     */
32
    public function getDefaultTemplate()
33
    {
34
        return new ArrayTemplate([
35
            'default' => 'Expected {{actual}} to be at least {{expected}}',
36
            'negated' => 'Expected {{actual}} to be below {{expected}}'
37
        ]);
38
    }
39
40
    /**
41
     * Return a default template for when a countable has been set.
42
     *
43
     * @return TemplateInterface
44
     */
45
    public function getDefaultCountableTemplate()
46
    {
47
        $count = $this->getCount();
48
        return new ArrayTemplate([
49
            'default' => "Expected {{actual}} to have a length at least {{expected}} but got $count",
50
            'negated' => 'Expected {{actual}} to have a length below {{expected}}'
51
        ]);
52
    }
53
}
54