TestEnvelope   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
dl 0
loc 37
rs 10
c 1
b 0
f 1
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A assertNotHasStamp() 0 8 1
A __call() 0 3 1
A assertHasStamp() 0 8 1
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