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

MinkExpectation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
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