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: