Passed
Pull Request — 1.x (#1)
by Kevin
01:50
created

MinkExpectation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 15
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 6 2
A __construct() 0 3 1
1
<?php
2
3
namespace Zenstruck\Browser\Assert\Assertion;
4
5
use Behat\Mink\Exception\ExpectationException;
6
use Zenstruck\Browser\Assert\Assertion;
7
use Zenstruck\Browser\Assert\Exception\AssertionFailed;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
final class MinkExpectation implements Assertion
13
{
14
    private $callback;
15
16
    public function __construct(callable $callback)
17
    {
18
        $this->callback = $callback;
19
    }
20
21
    public function __invoke(): void
22
    {
23
        try {
24
            ($this->callback)();
25
        } catch (ExpectationException $e) {
26
            throw new AssertionFailed($e->getMessage(), 0, $e);
27
        }
28
    }
29
}
30