Completed
Pull Request — master (#21)
by Erin
09:47
created

GreaterThanMatcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 3
c 3
b 0
f 3
lcom 1
cbo 2
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultTemplate() 0 7 1
A getDefaultCountableTemplate() 0 8 1
A matchNumeric() 0 4 1
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
 * GreaterThanMatcher determines if the actual value is greater than the expected value.
9
 *
10
 * @package Peridot\Leo\Matcher
11
 */
12
class GreaterThanMatcher extends CountableMatcher
13
{
14
    /**
15
     * {@inheritdoc}
16
     *
17
     * @return TemplateInterface
18
     */
19
    public function getDefaultTemplate()
20
    {
21
        return new ArrayTemplate([
22
            'default' => 'Expected {{actual}} to be above {{expected}}',
23
            'negated' => 'Expected {{actual}} to be at most {{expected}}'
24
        ]);
25
    }
26
27
    /**
28
     * @return ArrayTemplate
29
     */
30
    public function getDefaultCountableTemplate()
31
    {
32
        $count = $this->getCount();
33
        return new ArrayTemplate([
34
            'default' => "Expected {{actual}} to have a length above {{expected}} but got $count",
35
            'negated' => "Expected {{actual}} to not have a length above {{expected}}"
36
        ]);
37
    }
38
39
    /**
40
     * Match that actual number is greater than the expected value.
41
     *
42
     * @param $number
43
     * @return bool
44
     */
45
    protected function matchNumeric($number)
46
    {
47
        return $number > $this->expected;
48
    }
49
}
50