• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prooph / event-store-client / 9555551525

17 Jun 2024 10:16PM UTC coverage: 70.262% (-1.1%) from 71.395%
9555551525

push

github

prolic
update coveralls repo token

3466 of 4933 relevant lines covered (70.26%)

67.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/Internal/MessageHandler.php
1
<?php
2

3
/**
4
 * This file is part of `prooph/event-store-client`.
5
 * (c) 2018-2024 Alexander Miertsch <kontakt@codeliner.ws>
6
 * (c) 2018-2024 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace Prooph\EventStoreClient\Internal;
15

16
use Closure;
17
use Prooph\EventStore\Exception\RuntimeException;
18
use Prooph\EventStoreClient\Internal\Message\Message;
19

20
/** @internal */
21
class MessageHandler
22
{
23
    /** @var array<string, Closure> */
24
    private array $handlers = [];
25

26
    public function registerHandler(string $messageName, Closure $handler): void
27
    {
28
        $this->handlers[$messageName] = $handler;
420✔
29
    }
30

31
    public function handle(Message $message): void
32
    {
33
        if (! isset($this->handlers[$message::class])) {
408✔
34
            throw new RuntimeException('No handler found for ' . $message::class);
×
35
        }
36

37
        $this->handlers[$message::class]($message);
408✔
38
    }
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc