Total Complexity | 9 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Coverage | 58.81% |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7 | trait EnvelopeTrait |
||
8 | { |
||
9 | private MessageInterface $message; |
||
10 | |||
11 | 13 | public function getMessage(): MessageInterface |
|
12 | { |
||
13 | 13 | $message = $this->message; |
|
14 | 13 | while ($message instanceof EnvelopeInterface) { |
|
15 | 1 | $message = $message->getMessage(); |
|
16 | } |
||
17 | 13 | return $message; |
|
18 | } |
||
19 | |||
20 | public function withMessage(MessageInterface $message): self |
||
21 | { |
||
22 | $instance = clone $this; |
||
23 | $instance->message = $message; |
||
24 | |||
25 | return $instance; |
||
26 | } |
||
27 | |||
28 | 11 | public function getData(): mixed |
|
29 | { |
||
30 | 11 | return $this->message->getData(); |
|
31 | } |
||
32 | |||
33 | 8 | public static function fromMessage(MessageInterface $message): EnvelopeInterface |
|
34 | { |
||
35 | 8 | return new static($message); |
|
36 | } |
||
37 | |||
38 | 13 | public function getMetadata(): array |
|
39 | { |
||
40 | 13 | return array_merge( |
|
41 | 13 | $this->message->getMetadata(), |
|
42 | 13 | [ |
|
43 | 13 | self::ENVELOPE_STACK_KEY => array_merge( |
|
44 | 13 | $this->message->getMetadata()[self::ENVELOPE_STACK_KEY] ?? [], |
|
45 | 13 | [self::class], |
|
46 | 13 | ), |
|
47 | 13 | ], |
|
48 | 13 | $this->getEnvelopeMetadata(), |
|
49 | 13 | ); |
|
50 | } |
||
51 | |||
52 | public function getEnvelopeMetadata(): array |
||
53 | { |
||
54 | return []; |
||
55 | } |
||
56 | |||
57 | public function withData(mixed $data): self |
||
63 | } |
||
64 | |||
65 | public function withMetadata(array $metadata): self |
||
66 | { |
||
71 | } |
||
72 | } |
||
73 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.