Passed
Push — 1.x ( 3a787a...7d322e )
by Kevin
02:49 queued 25s
created

MinkAssertion   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

2 Methods

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