GreaterThanMatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultTemplate() 0 7 1
A getDefaultCountableTemplate() 0 9 1
A matchNumeric() 0 4 1
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