Completed
Pull Request — master (#543)
by
unknown
04:25 queued 42s
created

Constraint::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Mockery\Matcher;
3
4
class Constraint extends MatcherAbstract
5
{
6
    protected $constraint;
7
    protected $rethrow;
8
9
    /**
10
     * @param \PHPUnit_Framework_Constraint $constraint
11
     * @param bool $rethrow
12
     */
13 3
    public function __construct(\PHPUnit_Framework_Constraint $constraint, $rethrow = false)
14
    {
15 3
        $this->constraint = $constraint;
16 3
        $this->rethrow = $rethrow;
17 3
    }
18
19
    /**
20
     * @param mixed $actual
21
     * @return bool
22
     */
23 2
    public function match(&$actual)
24
    {
25
        try {
26 2
            $this->constraint->evaluate($actual);
27 1
            return true;
28 2
        } catch (\PHPUnit_Framework_AssertionFailedError $e) {
29 2
            if ($this->rethrow) {
30 1
                throw $e;
31
            }
32 1
            return false;
33
        }
34
    }
35
36
    /**
37
     *
38
     */
39 1
    public function __toString()
40
    {
41 1
        return '<Constraint>';
42
    }
43
}
44