@@ -13,11 +13,11 @@ |
||
| 13 | 13 | |
| 14 | 14 | interface VoterProvider |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Returns a voter for a permission. |
|
| 18 | - * |
|
| 19 | - * The dispatcher should fail if the function returns `null`, but a chain of voter providers |
|
| 20 | - * could invoke the next voter provider instead. |
|
| 21 | - */ |
|
| 22 | - public function getVoterForPermission(string $permission): ?Voter; |
|
| 16 | + /** |
|
| 17 | + * Returns a voter for a permission. |
|
| 18 | + * |
|
| 19 | + * The dispatcher should fail if the function returns `null`, but a chain of voter providers |
|
| 20 | + * could invoke the next voter provider instead. |
|
| 21 | + */ |
|
| 22 | + public function getVoterForPermission(string $permission): ?Voter; |
|
| 23 | 23 | } |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class VoterNotFound extends LogicException implements Exception |
| 21 | 21 | { |
| 22 | - public function __construct( |
|
| 23 | - public string $permission, |
|
| 24 | - ?Throwable $previous = null |
|
| 25 | - ) { |
|
| 26 | - parent::__construct("Voter not found for permission: $permission", previous: $previous); |
|
| 27 | - } |
|
| 22 | + public function __construct( |
|
| 23 | + public string $permission, |
|
| 24 | + ?Throwable $previous = null |
|
| 25 | + ) { |
|
| 26 | + parent::__construct("Voter not found for permission: $permission", previous: $previous); |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -23,6 +23,6 @@ |
||
| 23 | 23 | public string $permission, |
| 24 | 24 | ?Throwable $previous = null |
| 25 | 25 | ) { |
| 26 | - parent::__construct("Voter not found for permission: $permission", previous: $previous); |
|
| 26 | + parent::__construct("Voter not found for permission: $permission", previous : $previous); |
|
| 27 | 27 | } |
| 28 | 28 | } |
@@ -16,15 +16,15 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | interface HandlerProvider |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @param object $message |
|
| 21 | - * A message for which to return the relevant handler. |
|
| 22 | - * |
|
| 23 | - * @return callable |
|
| 24 | - * A callable that MUST be type-compatible with $message. |
|
| 25 | - * |
|
| 26 | - * @throws HandlerNotFound |
|
| 27 | - * The handler for the message cannot the found. |
|
| 28 | - */ |
|
| 29 | - public function getHandlerForMessage(object $message): callable; |
|
| 19 | + /** |
|
| 20 | + * @param object $message |
|
| 21 | + * A message for which to return the relevant handler. |
|
| 22 | + * |
|
| 23 | + * @return callable |
|
| 24 | + * A callable that MUST be type-compatible with $message. |
|
| 25 | + * |
|
| 26 | + * @throws HandlerNotFound |
|
| 27 | + * The handler for the message cannot the found. |
|
| 28 | + */ |
|
| 29 | + public function getHandlerForMessage(object $message): callable; |
|
| 30 | 30 | } |
@@ -18,19 +18,19 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | final class SimpleHandlerProvider implements HandlerProvider |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @param array<string, callable> $handlers |
|
| 23 | - */ |
|
| 24 | - public function __construct( |
|
| 25 | - private array $handlers |
|
| 26 | - ) { |
|
| 27 | - } |
|
| 21 | + /** |
|
| 22 | + * @param array<string, callable> $handlers |
|
| 23 | + */ |
|
| 24 | + public function __construct( |
|
| 25 | + private array $handlers |
|
| 26 | + ) { |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function getHandlerForMessage(object $message): callable |
|
| 30 | - { |
|
| 31 | - $class = get_class($message); |
|
| 29 | + public function getHandlerForMessage(object $message): callable |
|
| 30 | + { |
|
| 31 | + $class = get_class($message); |
|
| 32 | 32 | |
| 33 | - return $this->handlers[$class] |
|
| 34 | - ?? throw new HandlerNotFound("No handler for messages of type `$class`."); |
|
| 35 | - } |
|
| 33 | + return $this->handlers[$class] |
|
| 34 | + ?? throw new HandlerNotFound("No handler for messages of type `$class`."); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class NotFound extends LogicException implements Exception |
| 23 | 23 | { |
| 24 | - public function __construct(string $message, Throwable $previous = null) |
|
| 25 | - { |
|
| 26 | - parent::__construct($message, 0, $previous); |
|
| 27 | - } |
|
| 24 | + public function __construct(string $message, Throwable $previous = null) |
|
| 25 | + { |
|
| 26 | + parent::__construct($message, 0, $previous); |
|
| 27 | + } |
|
| 28 | 28 | } |