Completed
Pull Request — master (#22)
by Erin
02:35
created

PredicateMatcher::getDefaultTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
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
 * PredicateMatcher executes a function with the actual value. The PredicateMatcher returns
9
 * the result of that function call as a Match result.
10
 *
11
 * @package Peridot\Leo\Matcher
12
 */
13
class PredicateMatcher extends AbstractMatcher
14
{
15
    /**
16
     * {@inheritdoc}
17
     *
18
     * @return TemplateInterface
19
     */
20
    public function getDefaultTemplate()
21
    {
22
        return new ArrayTemplate([
23
            'default' => 'Expected {{actual}} to satisfy {{expected}}',
24
            'negated' => 'Expected {{actual}} to not satisfy {{expected}}'
25
        ]);
26
    }
27
28
    /**
29
     * Match actual value against the expected predicate.
30
     *
31
     * @param $actual
32
     * @return mixed
33
     */
34
    protected function doMatch($actual)
35
    {
36
        return (bool) call_user_func_array($this->expected, [$actual]);
37
    }
38
}
39