| 1 | <?php |
||
| 23 | class PHPUnitConstraint extends MatcherAbstract |
||
| 24 | { |
||
| 25 | protected $constraint; |
||
| 26 | protected $rethrow; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param \PHPUnit_Framework_Constraint $constraint |
||
| 30 | * @param bool $rethrow |
||
| 31 | */ |
||
| 32 | 3 | public function __construct(\PHPUnit_Framework_Constraint $constraint, $rethrow = false) |
|
| 37 | |||
| 38 | /** |
||
| 39 | * @param mixed $actual |
||
| 40 | * @return bool |
||
| 41 | */ |
||
| 42 | 2 | public function match(&$actual) |
|
| 43 | { |
||
| 44 | try { |
||
| 45 | 2 | $this->constraint->evaluate($actual); |
|
| 46 | 2 | return true; |
|
| 47 | } catch (\PHPUnit_Framework_AssertionFailedError $e) { |
||
| 48 | if ($this->rethrow) { |
||
| 49 | throw $e; |
||
| 50 | } |
||
| 51 | return false; |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * |
||
| 57 | */ |
||
| 58 | 1 | public function __toString() |
|
| 62 | } |
||
| 63 |