Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
CommandHandlerNamingConvention
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 resolveHandlerClass
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10namespace Phexium\Plugin\CommandBus\Internal;
11
12// Naming convention for Command -> Handler resolution.
13//
14// Pattern: {Name}Command -> {Name}Handler
15//
16// Examples:
17// - CreateBookCommand -> CreateBookHandler
18// - DeleteUserCommand -> DeleteUserHandler
19//
20// Requirements:
21// - Handler must be in the same namespace as Command
22// - Handler must implement CommandHandlerInterface
23// - Handler must be registered in the DI container
24final class CommandHandlerNamingConvention
25{
26    public static function resolveHandlerClass(string $commandClass): string
27    {
28        return preg_replace('/Command$/', 'Handler', $commandClass);
29    }
30}