Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| QueryHandlerNamingConvention | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| resolveHandlerClass | |
100.00% |
1 / 1 |
|
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 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace Phexium\Plugin\QueryBus\Internal; |
| 11 | |
| 12 | // Naming convention for Query -> Handler resolution. |
| 13 | // |
| 14 | // Pattern: {Name}Query -> {Name}Handler |
| 15 | // |
| 16 | // Examples: |
| 17 | // - ListBooksQuery -> ListBooksHandler |
| 18 | // - DetailBookQuery -> DetailBookHandler |
| 19 | // |
| 20 | // Requirements: |
| 21 | // - Handler must be in the same namespace as Query |
| 22 | // - Handler must implement QueryHandlerInterface |
| 23 | // - Handler must be registered in the DI container |
| 24 | final class QueryHandlerNamingConvention |
| 25 | { |
| 26 | public static function resolveHandlerClass(string $queryClass): string |
| 27 | { |
| 28 | return preg_replace('/Query$/', 'Handler', $queryClass); |
| 29 | } |
| 30 | } |