@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | private readonly ContainerInterface $container, |
| 25 | 25 | private readonly FactoryInterface $factory, |
| 26 | 26 | private readonly ?EventDispatcherInterface $dispatcher = null |
| 27 | - ) { |
|
| 27 | + ){ |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function getConnection(?string $name = null): QueueInterface |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | // Replaces alias with real pipeline name |
| 34 | 34 | $name = $this->config->getAliases()[$name] ?? $name; |
| 35 | 35 | |
| 36 | - if (!isset($this->pipelines[$name])) { |
|
| 36 | + if (!isset($this->pipelines[$name])){ |
|
| 37 | 37 | $this->pipelines[$name] = $this->resolveConnection($name); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $config = $this->config->getConnection($name); |
| 50 | 50 | |
| 51 | - try { |
|
| 51 | + try{ |
|
| 52 | 52 | $driver = $this->factory->make($config['driver'], $config); |
| 53 | 53 | |
| 54 | 54 | $core = new InterceptableCore( |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | $this->dispatcher |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | - foreach ($this->config->getPushInterceptors() as $interceptor) { |
|
| 60 | - if (\is_string($interceptor) || $interceptor instanceof Autowire) { |
|
| 59 | + foreach ($this->config->getPushInterceptors() as $interceptor){ |
|
| 60 | + if (\is_string($interceptor) || $interceptor instanceof Autowire){ |
|
| 61 | 61 | $interceptor = $this->container->get($interceptor); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | return new Queue($core); |
| 69 | - } catch (ContainerException $e) { |
|
| 69 | + }catch (ContainerException $e){ |
|
| 70 | 70 | throw new Exception\NotSupportedDriverException( |
| 71 | 71 | \sprintf( |
| 72 | 72 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -33,7 +33,8 @@ discard block |
||
| 33 | 33 | // Replaces alias with real pipeline name |
| 34 | 34 | $name = $this->config->getAliases()[$name] ?? $name; |
| 35 | 35 | |
| 36 | - if (!isset($this->pipelines[$name])) { |
|
| 36 | + if (!isset($this->pipelines[$name])) |
|
| 37 | + { |
|
| 37 | 38 | $this->pipelines[$name] = $this->resolveConnection($name); |
| 38 | 39 | } |
| 39 | 40 | |
@@ -48,7 +49,8 @@ discard block |
||
| 48 | 49 | { |
| 49 | 50 | $config = $this->config->getConnection($name); |
| 50 | 51 | |
| 51 | - try { |
|
| 52 | + try |
|
| 53 | + { |
|
| 52 | 54 | $driver = $this->factory->make($config['driver'], $config); |
| 53 | 55 | |
| 54 | 56 | $core = new InterceptableCore( |
@@ -56,8 +58,10 @@ discard block |
||
| 56 | 58 | $this->dispatcher |
| 57 | 59 | ); |
| 58 | 60 | |
| 59 | - foreach ($this->config->getPushInterceptors() as $interceptor) { |
|
| 60 | - if (\is_string($interceptor) || $interceptor instanceof Autowire) { |
|
| 61 | + foreach ($this->config->getPushInterceptors() as $interceptor) |
|
| 62 | + { |
|
| 63 | + if (\is_string($interceptor) || $interceptor instanceof Autowire) |
|
| 64 | + { |
|
| 61 | 65 | $interceptor = $this->container->get($interceptor); |
| 62 | 66 | } |
| 63 | 67 | |
@@ -66,7 +70,9 @@ discard block |
||
| 66 | 70 | } |
| 67 | 71 | |
| 68 | 72 | return new Queue($core); |
| 69 | - } catch (ContainerException $e) { |
|
| 73 | + } |
|
| 74 | + catch (ContainerException $e) |
|
| 75 | + { |
|
| 70 | 76 | throw new Exception\NotSupportedDriverException( |
| 71 | 77 | \sprintf( |
| 72 | 78 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function __construct( |
| 50 | 50 | private readonly ConfiguratorInterface $config |
| 51 | - ) { |
|
| 51 | + ){ |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function init( |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | $registry = $container->get(QueueRegistry::class); |
| 67 | 67 | $config = $container->get(QueueConfig::class); |
| 68 | 68 | |
| 69 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
| 69 | + foreach ($config->getRegistryHandlers() as $jobType => $handler){ |
|
| 70 | 70 | $registry->setHandler($jobType, $handler); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - foreach ($config->getRegistrySerializers() as $jobType => $serializer) { |
|
| 73 | + foreach ($config->getRegistrySerializers() as $jobType => $serializer){ |
|
| 74 | 74 | $registry->setSerializer($jobType, $serializer); |
| 75 | 75 | } |
| 76 | 76 | }); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * @param class-string<CoreInterceptorInterface>|CoreInterceptorInterface|Autowire $interceptor |
| 81 | 81 | */ |
| 82 | - public function addConsumeInterceptor(string|CoreInterceptorInterface|Autowire $interceptor): void |
|
| 82 | + public function addConsumeInterceptor(string | CoreInterceptorInterface | Autowire $interceptor): void |
|
| 83 | 83 | { |
| 84 | 84 | $this->config->modify( |
| 85 | 85 | QueueConfig::CONFIG, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * @param class-string<CoreInterceptorInterface>|CoreInterceptorInterface|Autowire $interceptor |
| 92 | 92 | */ |
| 93 | - public function addPushInterceptor(string|CoreInterceptorInterface|Autowire $interceptor): void |
|
| 93 | + public function addPushInterceptor(string | CoreInterceptorInterface | Autowire $interceptor): void |
|
| 94 | 94 | { |
| 95 | 95 | $this->config->modify( |
| 96 | 96 | QueueConfig::CONFIG, |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | ContainerInterface $container, |
| 116 | 116 | FactoryInterface $factory, |
| 117 | 117 | ContainerRegistry $registry |
| 118 | - ) { |
|
| 118 | + ){ |
|
| 119 | 119 | return new QueueRegistry($container, $factory, $registry); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | ): Handler { |
| 129 | 129 | $core = new InterceptableCore($core, $dispatcher); |
| 130 | 130 | |
| 131 | - foreach ($config->getConsumeInterceptors() as $interceptor) { |
|
| 132 | - if (\is_string($interceptor)) { |
|
| 131 | + foreach ($config->getConsumeInterceptors() as $interceptor){ |
|
| 132 | + if (\is_string($interceptor)){ |
|
| 133 | 133 | $interceptor = $container->get($interceptor); |
| 134 | - } elseif ($interceptor instanceof Autowire) { |
|
| 134 | + } elseif ($interceptor instanceof Autowire){ |
|
| 135 | 135 | $interceptor = $interceptor->resolve($factory); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -66,11 +66,13 @@ discard block |
||
| 66 | 66 | $registry = $container->get(QueueRegistry::class); |
| 67 | 67 | $config = $container->get(QueueConfig::class); |
| 68 | 68 | |
| 69 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
| 69 | + foreach ($config->getRegistryHandlers() as $jobType => $handler) |
|
| 70 | + { |
|
| 70 | 71 | $registry->setHandler($jobType, $handler); |
| 71 | 72 | } |
| 72 | 73 | |
| 73 | - foreach ($config->getRegistrySerializers() as $jobType => $serializer) { |
|
| 74 | + foreach ($config->getRegistrySerializers() as $jobType => $serializer) |
|
| 75 | + { |
|
| 74 | 76 | $registry->setSerializer($jobType, $serializer); |
| 75 | 77 | } |
| 76 | 78 | }); |
@@ -128,10 +130,14 @@ discard block |
||
| 128 | 130 | ): Handler { |
| 129 | 131 | $core = new InterceptableCore($core, $dispatcher); |
| 130 | 132 | |
| 131 | - foreach ($config->getConsumeInterceptors() as $interceptor) { |
|
| 132 | - if (\is_string($interceptor)) { |
|
| 133 | + foreach ($config->getConsumeInterceptors() as $interceptor) |
|
| 134 | + { |
|
| 135 | + if (\is_string($interceptor)) |
|
| 136 | + { |
|
| 133 | 137 | $interceptor = $container->get($interceptor); |
| 134 | - } elseif ($interceptor instanceof Autowire) { |
|
| 138 | + } |
|
| 139 | + elseif ($interceptor instanceof Autowire) |
|
| 140 | + { |
|
| 135 | 141 | $interceptor = $interceptor->resolve($factory); |
| 136 | 142 | } |
| 137 | 143 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | final class QueueManagerTest extends TestCase |
| 17 | 17 | { |
| 18 | - private m\MockInterface|FactoryInterface $factory; |
|
| 18 | + private m\MockInterface | FactoryInterface $factory; |
|
| 19 | 19 | |
| 20 | 20 | protected function setUp(): void |
| 21 | 21 | { |
@@ -88,7 +88,7 @@ |
||
| 88 | 88 | var_dump($name); |
| 89 | 89 | $result = ['sync' => $this->defaultQueue, 'test' => $this->testQueue][$name] ?? null; |
| 90 | 90 | |
| 91 | - if ($result === null) { |
|
| 91 | + if ($result === null){ |
|
| 92 | 92 | throw new NotFoundException(); |
| 93 | 93 | } |
| 94 | 94 | return $result; |
@@ -88,7 +88,8 @@ |
||
| 88 | 88 | var_dump($name); |
| 89 | 89 | $result = ['sync' => $this->defaultQueue, 'test' => $this->testQueue][$name] ?? null; |
| 90 | 90 | |
| 91 | - if ($result === null) { |
|
| 91 | + if ($result === null) |
|
| 92 | + { |
|
| 92 | 93 | throw new NotFoundException(); |
| 93 | 94 | } |
| 94 | 95 | return $result; |
@@ -18,24 +18,24 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function __construct( |
| 20 | 20 | private readonly QueueConnectionProviderInterface $queueManager |
| 21 | - ) { |
|
| 21 | + ){ |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function createInjection(ReflectionClass $class, string $context = null): QueueInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 27 | - if ($context === null) { |
|
| 26 | + try{ |
|
| 27 | + if ($context === null){ |
|
| 28 | 28 | $connection = $this->queueManager->getConnection(); |
| 29 | - } else { |
|
| 29 | + }else{ |
|
| 30 | 30 | // Get Queue by context |
| 31 | - try { |
|
| 31 | + try{ |
|
| 32 | 32 | $connection = $this->queueManager->getConnection($context); |
| 33 | - } catch (InvalidArgumentException) { |
|
| 33 | + }catch (InvalidArgumentException){ |
|
| 34 | 34 | // Case when context doesn't match to configured connections |
| 35 | 35 | return $this->queueManager->getConnection(); |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - } catch (\Throwable $e) { |
|
| 38 | + }catch (\Throwable $e){ |
|
| 39 | 39 | throw new ContainerException(\sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -23,19 +23,28 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function createInjection(ReflectionClass $class, string $context = null): QueueInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 27 | - if ($context === null) { |
|
| 26 | + try |
|
| 27 | + { |
|
| 28 | + if ($context === null) |
|
| 29 | + { |
|
| 28 | 30 | $connection = $this->queueManager->getConnection(); |
| 29 | - } else { |
|
| 31 | + } |
|
| 32 | + else |
|
| 33 | + { |
|
| 30 | 34 | // Get Queue by context |
| 31 | - try { |
|
| 35 | + try |
|
| 36 | + { |
|
| 32 | 37 | $connection = $this->queueManager->getConnection($context); |
| 33 | - } catch (InvalidArgumentException) { |
|
| 38 | + } |
|
| 39 | + catch (InvalidArgumentException) |
|
| 40 | + { |
|
| 34 | 41 | // Case when context doesn't match to configured connections |
| 35 | 42 | return $this->queueManager->getConnection(); |
| 36 | 43 | } |
| 37 | 44 | } |
| 38 | - } catch (\Throwable $e) { |
|
| 45 | + } |
|
| 46 | + catch (\Throwable $e) |
|
| 47 | + { |
|
| 39 | 48 | throw new ContainerException(\sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
| 40 | 49 | } |
| 41 | 50 | |