diff --git a/src/Provider/AdapterFactoryQueueProvider.php b/src/Provider/AdapterFactoryQueueProvider.php index 3346c667..feaed434 100644 --- a/src/Provider/AdapterFactoryQueueProvider.php +++ b/src/Provider/AdapterFactoryQueueProvider.php @@ -13,6 +13,12 @@ use function array_key_exists; use function sprintf; +/** + * Queue provider based on adapter definitions. + * + * @see https://github.com/yiisoft/definitions/ + * @see https://github.com/yiisoft/factory/ + */ final class AdapterFactoryQueueProvider implements QueueProviderInterface { /** @@ -23,6 +29,11 @@ final class AdapterFactoryQueueProvider implements QueueProviderInterface private readonly StrictFactory $factory; /** + * @param QueueInterface $baseQueue Base queue to use for creating queues. + * @param array $definitions Definitions to create adapters with indexed by channel names. + * @param ContainerInterface|null $container Container to use for resolving dependencies. + * @param bool $validate If definitions should be validated when set. + * * @psalm-param array $definitions * @throws InvalidQueueConfigException */ diff --git a/src/Provider/ChannelNotFoundException.php b/src/Provider/ChannelNotFoundException.php index fa2a6695..2538cda7 100644 --- a/src/Provider/ChannelNotFoundException.php +++ b/src/Provider/ChannelNotFoundException.php @@ -9,6 +9,9 @@ use function sprintf; +/** + * Thrown when channel is not found. + */ final class ChannelNotFoundException extends LogicException implements QueueProviderException { public function __construct(string $channel, int $code = 0, ?Throwable $previous = null) diff --git a/src/Provider/CompositeQueueProvider.php b/src/Provider/CompositeQueueProvider.php index 57152b94..cd7f36ca 100644 --- a/src/Provider/CompositeQueueProvider.php +++ b/src/Provider/CompositeQueueProvider.php @@ -6,6 +6,9 @@ use Yiisoft\Queue\QueueInterface; +/** + * Composite queue provider. + */ final class CompositeQueueProvider implements QueueProviderInterface { /** @@ -13,6 +16,9 @@ final class CompositeQueueProvider implements QueueProviderInterface */ private readonly array $providers; + /** + * @param QueueProviderInterface ...$providers Queue providers to use. + */ public function __construct( QueueProviderInterface ...$providers ) { diff --git a/src/Provider/InvalidQueueConfigException.php b/src/Provider/InvalidQueueConfigException.php index e1c24a0c..136fe746 100644 --- a/src/Provider/InvalidQueueConfigException.php +++ b/src/Provider/InvalidQueueConfigException.php @@ -6,6 +6,9 @@ use LogicException; +/** + * Thrown when queue configuration is invalid. + */ final class InvalidQueueConfigException extends LogicException implements QueueProviderException { } diff --git a/src/Provider/PrototypeQueueProvider.php b/src/Provider/PrototypeQueueProvider.php index bcb443d8..53b0d6e2 100644 --- a/src/Provider/PrototypeQueueProvider.php +++ b/src/Provider/PrototypeQueueProvider.php @@ -6,8 +6,15 @@ use Yiisoft\Queue\QueueInterface; +/** + * Queue provider that only changes the channel name of the base queue. + * It can be useful when your queues used the same adapter. + */ final class PrototypeQueueProvider implements QueueProviderInterface { + /** + * @param QueueInterface $baseQueue Base queue to use for creating queues. + */ public function __construct( private readonly QueueInterface $baseQueue, ) { diff --git a/src/Provider/QueueFactoryQueueProvider.php b/src/Provider/QueueFactoryQueueProvider.php index bbb5ff11..3b57375b 100644 --- a/src/Provider/QueueFactoryQueueProvider.php +++ b/src/Provider/QueueFactoryQueueProvider.php @@ -12,6 +12,12 @@ use function array_key_exists; use function sprintf; +/** + * Queue provider based on queue definitions. + * + * @see https://github.com/yiisoft/definitions/ + * @see https://github.com/yiisoft/factory/ + */ final class QueueFactoryQueueProvider implements QueueProviderInterface { /** @@ -22,6 +28,10 @@ final class QueueFactoryQueueProvider implements QueueProviderInterface private readonly StrictFactory $factory; /** + * @param array $definitions Definitions to create queues with indexed by channel names. + * @param ContainerInterface|null $container Container to use for resolving dependencies. + * @param bool $validate If definitions should be validated when set. + * * @psalm-param array $definitions * @throws InvalidQueueConfigException */ diff --git a/src/Provider/QueueProviderException.php b/src/Provider/QueueProviderException.php index 62a1a11c..17fa3bc4 100644 --- a/src/Provider/QueueProviderException.php +++ b/src/Provider/QueueProviderException.php @@ -6,6 +6,9 @@ use Throwable; +/** + * Base interface representing a generic exception in a queue provider. + */ interface QueueProviderException extends Throwable { } diff --git a/src/Provider/QueueProviderInterface.php b/src/Provider/QueueProviderInterface.php index 7c67c27e..a02cd42b 100644 --- a/src/Provider/QueueProviderInterface.php +++ b/src/Provider/QueueProviderInterface.php @@ -6,14 +6,30 @@ use Yiisoft\Queue\QueueInterface; +/** + * `QueueProviderInterface` provides a way to get a queue instance by channel name. + */ interface QueueProviderInterface { /** - * @throws InvalidQueueConfigException - * @throws ChannelNotFoundException - * @throws QueueProviderException + * Find a queue by channel name and returns it. + * + * @param string $channel Channel name. + * + * @return QueueInterface Queue instance. + * + * @throws InvalidQueueConfigException If the queue configuration is invalid. + * @throws ChannelNotFoundException If the channel is not found. + * @throws QueueProviderException If the queue provider fails to provide a queue. */ public function get(string $channel): QueueInterface; + /** + * Check if a queue with the specified channel name exists. + * + * @param string $channel Channel name. + * + * @return bool Whether the queue exists. + */ public function has(string $channel): bool; }