PredicateMatcher   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

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