-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwallowInboundEvent.php
More file actions
49 lines (42 loc) · 1.15 KB
/
SwallowInboundEvent.php
File metadata and controls
49 lines (42 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
* Copyright 2025 Cloud Creativity Limited
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
declare(strict_types=1);
namespace CloudCreativity\Modules\Application\InboundEventBus;
use CloudCreativity\Modules\Contracts\Toolkit\Messages\IntegrationEvent;
use CloudCreativity\Modules\Toolkit\ModuleBasename;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
final readonly class SwallowInboundEvent
{
/**
* SwallowInboundEvent constructor.
*
* @param ?LoggerInterface $logger
* @param string $level
*/
public function __construct(
private ?LoggerInterface $logger = null,
private string $level = LogLevel::DEBUG,
) {
}
/**
* Handle the event.
*
* @param IntegrationEvent $event
* @return void
*/
public function handle(IntegrationEvent $event): void
{
$name = ModuleBasename::tryFrom($event)?->toString() ?? $event::class;
$this->logger?->log(
$this->level,
"Swallowing inbound integration event {$name}.",
);
}
}