TestEnvelope::assertNotHasStamp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Zenstruck\Messenger\Test;
4
5
use Symfony\Component\Messenger\Envelope;
6
use Zenstruck\Assert;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 *
11
 * @mixin Envelope
12
 */
13
final class TestEnvelope
14
{
15
    private Envelope $envelope;
16
17
    public function __construct(Envelope $envelope)
18
    {
19
        $this->envelope = $envelope;
20
    }
21
22
    /**
23
     * @param mixed[] $arguments
24
     *
25
     * @return mixed
26
     */
27
    public function __call(string $name, array $arguments)
28
    {
29
        return $this->envelope->{$name}(...$arguments);
30
    }
31
32
    public function assertHasStamp(string $class): self
33
    {
34
        Assert::that($this->envelope->all($class))->isNotEmpty(
35
            'Expected to find stamp "{stamp}" but did not.',
36
            ['stamp' => $class]
37
        );
38
39
        return $this;
40
    }
41
42
    public function assertNotHasStamp(string $class): self
43
    {
44
        Assert::that($this->envelope->all($class))->isEmpty(
45
            'Expected to not find "{stamp}" but did.',
46
            ['stamp' => $class]
47
        );
48
49
        return $this;
50
    }
51
}
52