@@ -16,17 +16,17 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | final class HandlerProviderWithHandlers implements HandlerProvider |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @param array<class-string, callable> $handlers |
|
| 21 | - * Where _key_ is a message class and _value_ a handler for that message class. |
|
| 22 | - */ |
|
| 23 | - public function __construct( |
|
| 24 | - private array $handlers |
|
| 25 | - ) { |
|
| 26 | - } |
|
| 19 | + /** |
|
| 20 | + * @param array<class-string, callable> $handlers |
|
| 21 | + * Where _key_ is a message class and _value_ a handler for that message class. |
|
| 22 | + */ |
|
| 23 | + public function __construct( |
|
| 24 | + private array $handlers |
|
| 25 | + ) { |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public function getHandlerForMessage(object $message): ?callable |
|
| 29 | - { |
|
| 30 | - return $this->handlers[$message::class] ?? null; |
|
| 31 | - } |
|
| 28 | + public function getHandlerForMessage(object $message): ?callable |
|
| 29 | + { |
|
| 30 | + return $this->handlers[$message::class] ?? null; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -30,77 +30,77 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | final class MessageBusPass implements CompilerPassInterface |
| 32 | 32 | { |
| 33 | - public const DEFAULT_PARAMETER_FOR_MESSAGE_TO_HANDLER = 'message_bus.message_to_handler'; |
|
| 34 | - public const DEFAULT_TAG_FOR_HANDLER = 'message_bus.handler'; |
|
| 35 | - public const DEFAULT_ATTRIBUTE_FOR_MESSAGE = 'message'; |
|
| 36 | - public const DEFAULT_PARAMETER_FOR_PERMISSIONS_BY_MESSAGE = 'message_bus.permissions_by_message'; |
|
| 37 | - public const DEFAULT_TAG_FOR_PERMISSION = 'message_bus.permission'; |
|
| 38 | - public const DEFAULT_ATTRIBUTE_FOR_PERMISSION = 'permission'; |
|
| 39 | - public const DEFAULT_PARAMETER_FOR_PERMISSION_TO_VOTER = 'message_bus.permission_to_voter'; |
|
| 40 | - public const DEFAULT_TAG_FOR_VOTER = 'message_bus.voter'; |
|
| 41 | - |
|
| 42 | - public function __construct( |
|
| 43 | - private string $parameterForMessageToHandler = self::DEFAULT_PARAMETER_FOR_MESSAGE_TO_HANDLER, |
|
| 44 | - private string $tagForHandler = self::DEFAULT_TAG_FOR_HANDLER, |
|
| 45 | - private string $attributeForMessage = self::DEFAULT_ATTRIBUTE_FOR_MESSAGE, |
|
| 46 | - private string $parameterForPermissionsByMessage = self::DEFAULT_PARAMETER_FOR_PERMISSIONS_BY_MESSAGE, |
|
| 47 | - private string $tagForPermission = self::DEFAULT_TAG_FOR_PERMISSION, |
|
| 48 | - private string $attributeForPermission = self::DEFAULT_ATTRIBUTE_FOR_PERMISSION, |
|
| 49 | - private string $parameterForPermissionToVoter = self::DEFAULT_PARAMETER_FOR_PERMISSION_TO_VOTER, |
|
| 50 | - private string $tagForVoter = self::DEFAULT_TAG_FOR_VOTER, |
|
| 51 | - ) { |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function process(ContainerBuilder $container): void |
|
| 55 | - { |
|
| 56 | - $this->processHandlersAndPermissions($container); |
|
| 57 | - $this->processVoters($container); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Builds a map of message class to handler service identifier, |
|
| 62 | - * and another of permissions by message class. |
|
| 63 | - */ |
|
| 64 | - private function processHandlersAndPermissions(ContainerBuilder $container): void |
|
| 65 | - { |
|
| 66 | - $messageToHandler = []; |
|
| 67 | - $permissionsByMessage = []; |
|
| 68 | - |
|
| 69 | - foreach ($container->findTaggedServiceIds($this->tagForHandler) as $id => $hTags) { |
|
| 70 | - $message = $hTags[0][$this->attributeForMessage] |
|
| 71 | - ?? throw new InvalidArgumentException( |
|
| 72 | - "Missing attribute '$this->attributeForMessage' for service '$id'" |
|
| 73 | - ); |
|
| 74 | - |
|
| 75 | - $duplicate = $messageToHandler[$message] ?? null; |
|
| 76 | - |
|
| 77 | - if ($duplicate) { |
|
| 78 | - throw new LogicException("Unable to register handler '$id'" |
|
| 79 | - . ", the handler '$duplicate' is already registered for message class '$message'"); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - $messageToHandler[$message] = $id; |
|
| 83 | - |
|
| 84 | - foreach ($container->findDefinition($id)->getTag($this->tagForPermission) as $pTags) { |
|
| 85 | - $permissionsByMessage[$message][] = $pTags[$this->attributeForPermission]; |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $container->setParameter($this->parameterForMessageToHandler, $messageToHandler); |
|
| 90 | - $container->setParameter($this->parameterForPermissionsByMessage, $permissionsByMessage); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Builds a map of permission to voter service identifier. |
|
| 95 | - */ |
|
| 96 | - private function processVoters(ContainerBuilder $container): void |
|
| 97 | - { |
|
| 98 | - $permissionToVoter = []; |
|
| 99 | - |
|
| 100 | - foreach ($container->findTaggedServiceIds($this->tagForVoter) as $id => $tags) { |
|
| 101 | - $permissionToVoter[$tags[0][$this->attributeForPermission]] = $id; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $container->setParameter($this->parameterForPermissionToVoter, $permissionToVoter); |
|
| 105 | - } |
|
| 33 | + public const DEFAULT_PARAMETER_FOR_MESSAGE_TO_HANDLER = 'message_bus.message_to_handler'; |
|
| 34 | + public const DEFAULT_TAG_FOR_HANDLER = 'message_bus.handler'; |
|
| 35 | + public const DEFAULT_ATTRIBUTE_FOR_MESSAGE = 'message'; |
|
| 36 | + public const DEFAULT_PARAMETER_FOR_PERMISSIONS_BY_MESSAGE = 'message_bus.permissions_by_message'; |
|
| 37 | + public const DEFAULT_TAG_FOR_PERMISSION = 'message_bus.permission'; |
|
| 38 | + public const DEFAULT_ATTRIBUTE_FOR_PERMISSION = 'permission'; |
|
| 39 | + public const DEFAULT_PARAMETER_FOR_PERMISSION_TO_VOTER = 'message_bus.permission_to_voter'; |
|
| 40 | + public const DEFAULT_TAG_FOR_VOTER = 'message_bus.voter'; |
|
| 41 | + |
|
| 42 | + public function __construct( |
|
| 43 | + private string $parameterForMessageToHandler = self::DEFAULT_PARAMETER_FOR_MESSAGE_TO_HANDLER, |
|
| 44 | + private string $tagForHandler = self::DEFAULT_TAG_FOR_HANDLER, |
|
| 45 | + private string $attributeForMessage = self::DEFAULT_ATTRIBUTE_FOR_MESSAGE, |
|
| 46 | + private string $parameterForPermissionsByMessage = self::DEFAULT_PARAMETER_FOR_PERMISSIONS_BY_MESSAGE, |
|
| 47 | + private string $tagForPermission = self::DEFAULT_TAG_FOR_PERMISSION, |
|
| 48 | + private string $attributeForPermission = self::DEFAULT_ATTRIBUTE_FOR_PERMISSION, |
|
| 49 | + private string $parameterForPermissionToVoter = self::DEFAULT_PARAMETER_FOR_PERMISSION_TO_VOTER, |
|
| 50 | + private string $tagForVoter = self::DEFAULT_TAG_FOR_VOTER, |
|
| 51 | + ) { |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function process(ContainerBuilder $container): void |
|
| 55 | + { |
|
| 56 | + $this->processHandlersAndPermissions($container); |
|
| 57 | + $this->processVoters($container); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Builds a map of message class to handler service identifier, |
|
| 62 | + * and another of permissions by message class. |
|
| 63 | + */ |
|
| 64 | + private function processHandlersAndPermissions(ContainerBuilder $container): void |
|
| 65 | + { |
|
| 66 | + $messageToHandler = []; |
|
| 67 | + $permissionsByMessage = []; |
|
| 68 | + |
|
| 69 | + foreach ($container->findTaggedServiceIds($this->tagForHandler) as $id => $hTags) { |
|
| 70 | + $message = $hTags[0][$this->attributeForMessage] |
|
| 71 | + ?? throw new InvalidArgumentException( |
|
| 72 | + "Missing attribute '$this->attributeForMessage' for service '$id'" |
|
| 73 | + ); |
|
| 74 | + |
|
| 75 | + $duplicate = $messageToHandler[$message] ?? null; |
|
| 76 | + |
|
| 77 | + if ($duplicate) { |
|
| 78 | + throw new LogicException("Unable to register handler '$id'" |
|
| 79 | + . ", the handler '$duplicate' is already registered for message class '$message'"); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + $messageToHandler[$message] = $id; |
|
| 83 | + |
|
| 84 | + foreach ($container->findDefinition($id)->getTag($this->tagForPermission) as $pTags) { |
|
| 85 | + $permissionsByMessage[$message][] = $pTags[$this->attributeForPermission]; |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $container->setParameter($this->parameterForMessageToHandler, $messageToHandler); |
|
| 90 | + $container->setParameter($this->parameterForPermissionsByMessage, $permissionsByMessage); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Builds a map of permission to voter service identifier. |
|
| 95 | + */ |
|
| 96 | + private function processVoters(ContainerBuilder $container): void |
|
| 97 | + { |
|
| 98 | + $permissionToVoter = []; |
|
| 99 | + |
|
| 100 | + foreach ($container->findTaggedServiceIds($this->tagForVoter) as $id => $tags) { |
|
| 101 | + $permissionToVoter[$tags[0][$this->attributeForPermission]] = $id; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + $container->setParameter($this->parameterForPermissionToVoter, $permissionToVoter); |
|
| 105 | + } |
|
| 106 | 106 | } |
@@ -30,76 +30,76 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | final class MessageBusPassWithAttributes implements CompilerPassInterface |
| 32 | 32 | { |
| 33 | - public function __construct( |
|
| 34 | - private string $tagForHandler = MessageBusPass::DEFAULT_TAG_FOR_HANDLER, |
|
| 35 | - private string $attributeForMessage = MessageBusPass::DEFAULT_ATTRIBUTE_FOR_MESSAGE, |
|
| 36 | - private string $tagForPermission = MessageBusPass::DEFAULT_TAG_FOR_PERMISSION, |
|
| 37 | - private string $attributeForPermission = MessageBusPass::DEFAULT_ATTRIBUTE_FOR_PERMISSION, |
|
| 38 | - private string $tagForVoter = MessageBusPass::DEFAULT_TAG_FOR_VOTER, |
|
| 39 | - ) { |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @throws ReflectionException |
|
| 44 | - */ |
|
| 45 | - public function process(ContainerBuilder $container): void |
|
| 46 | - { |
|
| 47 | - /** @var array<class-string, Definition> $definitions */ |
|
| 48 | - $definitions = []; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @var array<class-string, string[]> $permissions |
|
| 52 | - * Where _key_ is a command and _value_ its associated permissions. |
|
| 53 | - */ |
|
| 54 | - $permissions = []; |
|
| 55 | - |
|
| 56 | - foreach (Attributes::findTargetClasses(Attribute\Permission::class) as $targetClass) { |
|
| 57 | - $permissions[$targetClass->name][] = $targetClass->attribute->permission; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - foreach (Attributes::findTargetClasses(Attribute\Handler::class) as $targetClass) { |
|
| 61 | - $handler = $targetClass->name; |
|
| 62 | - $message = self::resolveMessage($handler); |
|
| 63 | - |
|
| 64 | - $definition = new Definition($handler); |
|
| 65 | - $definition->addTag($this->tagForHandler, [ $this->attributeForMessage => $message ]); |
|
| 66 | - |
|
| 67 | - foreach ($permissions[$message] ?? [] as $permission) { |
|
| 68 | - $definition->addTag($this->tagForPermission, [ $this->attributeForPermission => $permission ]); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $definitions[$handler] = $definition; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - foreach (Attributes::findTargetClasses(Attribute\Vote::class) as $targetClass) { |
|
| 75 | - $voter = $targetClass->name; |
|
| 76 | - $permission = $targetClass->attribute->permission; |
|
| 77 | - |
|
| 78 | - $definition = new Definition($voter); |
|
| 79 | - $definition->addTag($this->tagForVoter, [ $this->attributeForPermission => $permission ]); |
|
| 80 | - |
|
| 81 | - $definitions[$voter] = $definition; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - $container->addDefinitions($definitions); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @param class-string $handler |
|
| 89 | - * |
|
| 90 | - * @return class-string |
|
| 91 | - * |
|
| 92 | - * @throws ReflectionException |
|
| 93 | - */ |
|
| 94 | - private static function resolveMessage(string $handler): string |
|
| 95 | - { |
|
| 96 | - $type = (new ReflectionMethod($handler, '__invoke')) |
|
| 97 | - ->getParameters()[0] |
|
| 98 | - ->getType() ?? throw new LogicException("Expected a type for the first argument"); |
|
| 99 | - |
|
| 100 | - assert($type instanceof ReflectionNamedType); |
|
| 101 | - |
|
| 102 | - // @phpstan-ignore-next-line |
|
| 103 | - return $type->getName(); |
|
| 104 | - } |
|
| 33 | + public function __construct( |
|
| 34 | + private string $tagForHandler = MessageBusPass::DEFAULT_TAG_FOR_HANDLER, |
|
| 35 | + private string $attributeForMessage = MessageBusPass::DEFAULT_ATTRIBUTE_FOR_MESSAGE, |
|
| 36 | + private string $tagForPermission = MessageBusPass::DEFAULT_TAG_FOR_PERMISSION, |
|
| 37 | + private string $attributeForPermission = MessageBusPass::DEFAULT_ATTRIBUTE_FOR_PERMISSION, |
|
| 38 | + private string $tagForVoter = MessageBusPass::DEFAULT_TAG_FOR_VOTER, |
|
| 39 | + ) { |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @throws ReflectionException |
|
| 44 | + */ |
|
| 45 | + public function process(ContainerBuilder $container): void |
|
| 46 | + { |
|
| 47 | + /** @var array<class-string, Definition> $definitions */ |
|
| 48 | + $definitions = []; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @var array<class-string, string[]> $permissions |
|
| 52 | + * Where _key_ is a command and _value_ its associated permissions. |
|
| 53 | + */ |
|
| 54 | + $permissions = []; |
|
| 55 | + |
|
| 56 | + foreach (Attributes::findTargetClasses(Attribute\Permission::class) as $targetClass) { |
|
| 57 | + $permissions[$targetClass->name][] = $targetClass->attribute->permission; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + foreach (Attributes::findTargetClasses(Attribute\Handler::class) as $targetClass) { |
|
| 61 | + $handler = $targetClass->name; |
|
| 62 | + $message = self::resolveMessage($handler); |
|
| 63 | + |
|
| 64 | + $definition = new Definition($handler); |
|
| 65 | + $definition->addTag($this->tagForHandler, [ $this->attributeForMessage => $message ]); |
|
| 66 | + |
|
| 67 | + foreach ($permissions[$message] ?? [] as $permission) { |
|
| 68 | + $definition->addTag($this->tagForPermission, [ $this->attributeForPermission => $permission ]); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $definitions[$handler] = $definition; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + foreach (Attributes::findTargetClasses(Attribute\Vote::class) as $targetClass) { |
|
| 75 | + $voter = $targetClass->name; |
|
| 76 | + $permission = $targetClass->attribute->permission; |
|
| 77 | + |
|
| 78 | + $definition = new Definition($voter); |
|
| 79 | + $definition->addTag($this->tagForVoter, [ $this->attributeForPermission => $permission ]); |
|
| 80 | + |
|
| 81 | + $definitions[$voter] = $definition; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + $container->addDefinitions($definitions); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @param class-string $handler |
|
| 89 | + * |
|
| 90 | + * @return class-string |
|
| 91 | + * |
|
| 92 | + * @throws ReflectionException |
|
| 93 | + */ |
|
| 94 | + private static function resolveMessage(string $handler): string |
|
| 95 | + { |
|
| 96 | + $type = (new ReflectionMethod($handler, '__invoke')) |
|
| 97 | + ->getParameters()[0] |
|
| 98 | + ->getType() ?? throw new LogicException("Expected a type for the first argument"); |
|
| 99 | + |
|
| 100 | + assert($type instanceof ReflectionNamedType); |
|
| 101 | + |
|
| 102 | + // @phpstan-ignore-next-line |
|
| 103 | + return $type->getName(); |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | $message = self::resolveMessage($handler); |
| 63 | 63 | |
| 64 | 64 | $definition = new Definition($handler); |
| 65 | - $definition->addTag($this->tagForHandler, [ $this->attributeForMessage => $message ]); |
|
| 65 | + $definition->addTag($this->tagForHandler, [$this->attributeForMessage => $message]); |
|
| 66 | 66 | |
| 67 | 67 | foreach ($permissions[$message] ?? [] as $permission) { |
| 68 | - $definition->addTag($this->tagForPermission, [ $this->attributeForPermission => $permission ]); |
|
| 68 | + $definition->addTag($this->tagForPermission, [$this->attributeForPermission => $permission]); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $definitions[$handler] = $definition; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $permission = $targetClass->attribute->permission; |
| 77 | 77 | |
| 78 | 78 | $definition = new Definition($voter); |
| 79 | - $definition->addTag($this->tagForVoter, [ $this->attributeForPermission => $permission ]); |
|
| 79 | + $definition->addTag($this->tagForVoter, [$this->attributeForPermission => $permission]); |
|
| 80 | 80 | |
| 81 | 81 | $definitions[$voter] = $definition; |
| 82 | 82 | } |
@@ -16,17 +16,17 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | final class DispatcherWithHandlerProvider implements Dispatcher |
| 18 | 18 | { |
| 19 | - public function __construct( |
|
| 20 | - private HandlerProvider $handlerProvider |
|
| 21 | - ) { |
|
| 22 | - } |
|
| 19 | + public function __construct( |
|
| 20 | + private HandlerProvider $handlerProvider |
|
| 21 | + ) { |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function dispatch(object $message) |
|
| 25 | - { |
|
| 26 | - $class = $message::class; |
|
| 27 | - $handler = $this->handlerProvider->getHandlerForMessage($message) |
|
| 28 | - ?? throw new HandlerNotFound("No handler for messages of type `$class`"); |
|
| 24 | + public function dispatch(object $message) |
|
| 25 | + { |
|
| 26 | + $class = $message::class; |
|
| 27 | + $handler = $this->handlerProvider->getHandlerForMessage($message) |
|
| 28 | + ?? throw new HandlerNotFound("No handler for messages of type `$class`"); |
|
| 29 | 29 | |
| 30 | - return $handler($message); |
|
| 31 | - } |
|
| 30 | + return $handler($message); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class HandlerNotFound extends LogicException implements Exception |
| 21 | 21 | { |
| 22 | - public function __construct(string $message, Throwable $previous = null) |
|
| 23 | - { |
|
| 24 | - parent::__construct($message, previous: $previous); |
|
| 25 | - } |
|
| 22 | + public function __construct(string $message, Throwable $previous = null) |
|
| 23 | + { |
|
| 24 | + parent::__construct($message, previous: $previous); |
|
| 25 | + } |
|
| 26 | 26 | } |
@@ -16,26 +16,26 @@ |
||
| 16 | 16 | |
| 17 | 17 | final class HandlerProviderWithContainer implements HandlerProvider |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @param array<class-string, string> $messageToHandler |
|
| 21 | - * Where _key_ is a message class and _value_ the service identifier of its handler. |
|
| 22 | - */ |
|
| 23 | - public function __construct( |
|
| 24 | - private ContainerInterface $container, |
|
| 25 | - private array $messageToHandler |
|
| 26 | - ) { |
|
| 27 | - $this->container = $container; |
|
| 28 | - $this->messageToHandler = $messageToHandler; |
|
| 29 | - } |
|
| 19 | + /** |
|
| 20 | + * @param array<class-string, string> $messageToHandler |
|
| 21 | + * Where _key_ is a message class and _value_ the service identifier of its handler. |
|
| 22 | + */ |
|
| 23 | + public function __construct( |
|
| 24 | + private ContainerInterface $container, |
|
| 25 | + private array $messageToHandler |
|
| 26 | + ) { |
|
| 27 | + $this->container = $container; |
|
| 28 | + $this->messageToHandler = $messageToHandler; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function getHandlerForMessage(object $message): ?callable |
|
| 32 | - { |
|
| 33 | - $id = $this->messageToHandler[$message::class] ?? null; |
|
| 31 | + public function getHandlerForMessage(object $message): ?callable |
|
| 32 | + { |
|
| 33 | + $id = $this->messageToHandler[$message::class] ?? null; |
|
| 34 | 34 | |
| 35 | - if (!$id) { |
|
| 36 | - return null; |
|
| 37 | - } |
|
| 35 | + if (!$id) { |
|
| 36 | + return null; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - return $this->container->get($id); // @phpstan-ignore-line |
|
| 40 | - } |
|
| 39 | + return $this->container->get($id); // @phpstan-ignore-line |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | #[Attribute(Attribute::TARGET_CLASS)] |
| 13 | 13 | final class Vote |
| 14 | 14 | { |
| 15 | - public function __construct( |
|
| 16 | - public string $permission, |
|
| 17 | - ) { |
|
| 18 | - } |
|
| 15 | + public function __construct( |
|
| 16 | + public string $permission, |
|
| 17 | + ) { |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | #[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] |
| 24 | 24 | final class Permission |
| 25 | 25 | { |
| 26 | - public function __construct( |
|
| 27 | - public string $permission |
|
| 28 | - ) { |
|
| 29 | - } |
|
| 26 | + public function __construct( |
|
| 27 | + public string $permission |
|
| 28 | + ) { |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -16,24 +16,24 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | final class HandlerProviderWithChain implements HandlerProvider |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @param iterable<HandlerProvider> $providers |
|
| 21 | - */ |
|
| 22 | - public function __construct( |
|
| 23 | - private iterable $providers |
|
| 24 | - ) { |
|
| 25 | - } |
|
| 19 | + /** |
|
| 20 | + * @param iterable<HandlerProvider> $providers |
|
| 21 | + */ |
|
| 22 | + public function __construct( |
|
| 23 | + private iterable $providers |
|
| 24 | + ) { |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function getHandlerForMessage(object $message): ?callable |
|
| 28 | - { |
|
| 29 | - foreach ($this->providers as $provider) { |
|
| 30 | - $handler = $provider->getHandlerForMessage($message); |
|
| 27 | + public function getHandlerForMessage(object $message): ?callable |
|
| 28 | + { |
|
| 29 | + foreach ($this->providers as $provider) { |
|
| 30 | + $handler = $provider->getHandlerForMessage($message); |
|
| 31 | 31 | |
| 32 | - if ($handler) { |
|
| 33 | - return $handler; |
|
| 34 | - } |
|
| 35 | - } |
|
| 32 | + if ($handler) { |
|
| 33 | + return $handler; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - return null; |
|
| 38 | - } |
|
| 37 | + return null; |
|
| 38 | + } |
|
| 39 | 39 | } |