@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | private readonly ContainerInterface $container, |
27 | 27 | private readonly FactoryInterface $factory, |
28 | 28 | private readonly HandlerRegistryInterface $fallbackHandlers |
29 | - ) { |
|
29 | + ){ |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Associate specific job type with handler class or object |
34 | 34 | */ |
35 | - public function setHandler(string $jobType, HandlerInterface|string $handler): void |
|
35 | + public function setHandler(string $jobType, HandlerInterface | string $handler): void |
|
36 | 36 | { |
37 | 37 | $this->handlers[$jobType] = $handler; |
38 | 38 | } |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function getHandler(string $jobType): HandlerInterface |
45 | 45 | { |
46 | - if (isset($this->handlers[$jobType])) { |
|
47 | - if ($this->handlers[$jobType] instanceof HandlerInterface) { |
|
46 | + if (isset($this->handlers[$jobType])){ |
|
47 | + if ($this->handlers[$jobType] instanceof HandlerInterface){ |
|
48 | 48 | return $this->handlers[$jobType]; |
49 | 49 | } |
50 | 50 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @throws InvalidArgumentException |
63 | 63 | */ |
64 | - public function setSerializer(string $jobType, SerializerInterface|string|Autowire $serializer): void |
|
64 | + public function setSerializer(string $jobType, SerializerInterface | string | Autowire $serializer): void |
|
65 | 65 | { |
66 | 66 | $this->serializers[$jobType] = $this->resolveSerializer($serializer); |
67 | 67 | } |
@@ -71,15 +71,14 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getSerializer(?string $jobType = null): SerializerInterface |
73 | 73 | { |
74 | - if ($jobType && $this->hasSerializer($jobType)) { |
|
74 | + if ($jobType && $this->hasSerializer($jobType)){ |
|
75 | 75 | return $this->serializers[$jobType]; |
76 | 76 | } |
77 | 77 | |
78 | 78 | $config = $this->container->get(QueueConfig::class); |
79 | 79 | |
80 | 80 | return $config->getDefaultSerializer() === null ? |
81 | - $this->container->get(SerializerManager::class)->getSerializer() : |
|
82 | - $this->resolveSerializer($config->getDefaultSerializer()); |
|
81 | + $this->container->get(SerializerManager::class)->getSerializer() : $this->resolveSerializer($config->getDefaultSerializer()); |
|
83 | 82 | } |
84 | 83 | |
85 | 84 | public function hasSerializer(string $jobType): bool |
@@ -92,22 +91,21 @@ discard block |
||
92 | 91 | * |
93 | 92 | * @throws InvalidArgumentException |
94 | 93 | */ |
95 | - private function resolveSerializer(SerializerInterface|string|Autowire $serializer): SerializerInterface |
|
94 | + private function resolveSerializer(SerializerInterface | string | Autowire $serializer): SerializerInterface |
|
96 | 95 | { |
97 | - if ($serializer instanceof Autowire) { |
|
96 | + if ($serializer instanceof Autowire){ |
|
98 | 97 | $serializer = $serializer->resolve($this->factory); |
99 | 98 | } |
100 | 99 | |
101 | - if (\is_string($serializer)) { |
|
100 | + if (\is_string($serializer)){ |
|
102 | 101 | $registry = $this->container->get(SerializerRegistryInterface::class); |
103 | 102 | \assert($registry instanceof SerializerRegistryInterface); |
104 | 103 | |
105 | 104 | $serializer = $registry->has($serializer) ? |
106 | - $registry->get($serializer) : |
|
107 | - $this->container->get($serializer); |
|
105 | + $registry->get($serializer) : $this->container->get($serializer); |
|
108 | 106 | } |
109 | 107 | |
110 | - if (!$serializer instanceof SerializerInterface) { |
|
108 | + if (!$serializer instanceof SerializerInterface){ |
|
111 | 109 | throw new InvalidArgumentException(\sprintf( |
112 | 110 | 'Serializer must be an instance of `SerializerInterface` but `%s` given.', |
113 | 111 | \get_debug_type($serializer) |
@@ -43,8 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function getHandler(string $jobType): HandlerInterface |
45 | 45 | { |
46 | - if (isset($this->handlers[$jobType])) { |
|
47 | - if ($this->handlers[$jobType] instanceof HandlerInterface) { |
|
46 | + if (isset($this->handlers[$jobType])) |
|
47 | + { |
|
48 | + if ($this->handlers[$jobType] instanceof HandlerInterface) |
|
49 | + { |
|
48 | 50 | return $this->handlers[$jobType]; |
49 | 51 | } |
50 | 52 | |
@@ -71,7 +73,8 @@ discard block |
||
71 | 73 | */ |
72 | 74 | public function getSerializer(?string $jobType = null): SerializerInterface |
73 | 75 | { |
74 | - if ($jobType && $this->hasSerializer($jobType)) { |
|
76 | + if ($jobType && $this->hasSerializer($jobType)) |
|
77 | + { |
|
75 | 78 | return $this->serializers[$jobType]; |
76 | 79 | } |
77 | 80 | |
@@ -94,11 +97,13 @@ discard block |
||
94 | 97 | */ |
95 | 98 | private function resolveSerializer(SerializerInterface|string|Autowire $serializer): SerializerInterface |
96 | 99 | { |
97 | - if ($serializer instanceof Autowire) { |
|
100 | + if ($serializer instanceof Autowire) |
|
101 | + { |
|
98 | 102 | $serializer = $serializer->resolve($this->factory); |
99 | 103 | } |
100 | 104 | |
101 | - if (\is_string($serializer)) { |
|
105 | + if (\is_string($serializer)) |
|
106 | + { |
|
102 | 107 | $registry = $this->container->get(SerializerRegistryInterface::class); |
103 | 108 | \assert($registry instanceof SerializerRegistryInterface); |
104 | 109 | |
@@ -107,7 +112,8 @@ discard block |
||
107 | 112 | $this->container->get($serializer); |
108 | 113 | } |
109 | 114 | |
110 | - if (!$serializer instanceof SerializerInterface) { |
|
115 | + if (!$serializer instanceof SerializerInterface) |
|
116 | + { |
|
111 | 117 | throw new InvalidArgumentException(\sprintf( |
112 | 118 | 'Serializer must be an instance of `SerializerInterface` but `%s` given.', |
113 | 119 | \get_debug_type($serializer) |
@@ -11,7 +11,7 @@ |
||
11 | 11 | public function __construct( |
12 | 12 | string $reason = '', |
13 | 13 | private ?OptionsInterface $options = null |
14 | - ) { |
|
14 | + ){ |
|
15 | 15 | parent::__construct($reason); |
16 | 16 | } |
17 | 17 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | private readonly ExceptionReporterInterface $reporter |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function handle(string $driver, string $queue, string $job, array $payload, \Throwable $e): void |
@@ -16,19 +16,19 @@ |
||
16 | 16 | |
17 | 17 | public function __construct( |
18 | 18 | private readonly ContainerInterface $container |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | $this->inflector = (new InflectorFactory())->build(); |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function getHandler(string $jobType): HandlerInterface |
24 | 24 | { |
25 | - try { |
|
25 | + try{ |
|
26 | 26 | $handler = $this->container->get($this->className($jobType)); |
27 | - } catch (ContainerException $e) { |
|
27 | + }catch (ContainerException $e){ |
|
28 | 28 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
29 | 29 | } |
30 | 30 | |
31 | - if (!$handler instanceof HandlerInterface) { |
|
31 | + if (!$handler instanceof HandlerInterface){ |
|
32 | 32 | throw new JobException(\sprintf('Unable to resolve job handler for `%s`', $jobType)); |
33 | 33 | } |
34 | 34 |
@@ -22,13 +22,17 @@ |
||
22 | 22 | |
23 | 23 | public function getHandler(string $jobType): HandlerInterface |
24 | 24 | { |
25 | - try { |
|
25 | + try |
|
26 | + { |
|
26 | 27 | $handler = $this->container->get($this->className($jobType)); |
27 | - } catch (ContainerException $e) { |
|
28 | + } |
|
29 | + catch (ContainerException $e) |
|
30 | + { |
|
28 | 31 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
29 | 32 | } |
30 | 33 | |
31 | - if (!$handler instanceof HandlerInterface) { |
|
34 | + if (!$handler instanceof HandlerInterface) |
|
35 | + { |
|
32 | 36 | throw new JobException(\sprintf('Unable to resolve job handler for `%s`', $jobType)); |
33 | 37 | } |
34 | 38 |
@@ -19,13 +19,13 @@ |
||
19 | 19 | |
20 | 20 | public function __construct( |
21 | 21 | private readonly Handler $coreHandler |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** @inheritdoc */ |
26 | 26 | public function push(string $name, array $payload = [], OptionsInterface $options = null): string |
27 | 27 | { |
28 | - if ($options !== null && $options->getDelay()) { |
|
28 | + if ($options !== null && $options->getDelay()){ |
|
29 | 29 | \sleep($options->getDelay()); |
30 | 30 | } |
31 | 31 |
@@ -25,7 +25,8 @@ |
||
25 | 25 | /** @inheritdoc */ |
26 | 26 | public function push(string $name, array $payload = [], OptionsInterface $options = null): string |
27 | 27 | { |
28 | - if ($options !== null && $options->getDelay()) { |
|
28 | + if ($options !== null && $options->getDelay()) |
|
29 | + { |
|
29 | 30 | \sleep($options->getDelay()); |
30 | 31 | } |
31 | 32 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | public function __construct( |
24 | 24 | private readonly HandlerRegistryInterface $registry, |
25 | 25 | private readonly ?EventDispatcherInterface $dispatcher = null |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -13,16 +13,16 @@ |
||
13 | 13 | { |
14 | 14 | public function __construct( |
15 | 15 | private readonly FailedJobHandlerInterface $handler |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** @psalm-suppress ParamNameMismatch */ |
20 | 20 | public function process(string $name, string $action, array $parameters, CoreInterface $core): mixed |
21 | 21 | { |
22 | - try { |
|
22 | + try{ |
|
23 | 23 | return $core->callAction($name, $action, $parameters); |
24 | - } catch (\Throwable $e) { |
|
25 | - if (!$e instanceof StateException) { |
|
24 | + }catch (\Throwable $e){ |
|
25 | + if (!$e instanceof StateException){ |
|
26 | 26 | $this->handler->handle( |
27 | 27 | $parameters['driver'], |
28 | 28 | $parameters['queue'], |
@@ -19,10 +19,14 @@ |
||
19 | 19 | /** @psalm-suppress ParamNameMismatch */ |
20 | 20 | public function process(string $name, string $action, array $parameters, CoreInterface $core): mixed |
21 | 21 | { |
22 | - try { |
|
22 | + try |
|
23 | + { |
|
23 | 24 | return $core->callAction($name, $action, $parameters); |
24 | - } catch (\Throwable $e) { |
|
25 | - if (!$e instanceof StateException) { |
|
25 | + } |
|
26 | + catch (\Throwable $e) |
|
27 | + { |
|
28 | + if (!$e instanceof StateException) |
|
29 | + { |
|
26 | 30 | $this->handler->handle( |
27 | 31 | $parameters['driver'], |
28 | 32 | $parameters['queue'], |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | private readonly CoreInterface $core |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | |
30 | 30 | public function __construct($name = null, array $data = [], $dataName = '') |
31 | 31 | { |
32 | - $this->storage = new Storage($this->dir() . '/Fixtures/'); |
|
32 | + $this->storage = new Storage($this->dir().'/Fixtures/'); |
|
33 | 33 | parent::__construct($name, $data, $dataName); |
34 | 34 | } |
35 | 35 | |
36 | 36 | public function setUp(): void |
37 | 37 | { |
38 | - if (!\class_exists(Kernel::class)) { |
|
38 | + if (!\class_exists(Kernel::class)){ |
|
39 | 39 | $this->markTestSkipped('A "spiral/framework" dependency is required to run these tests'); |
40 | 40 | } |
41 | 41 | |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | 'cache' => sys_get_temp_dir() |
47 | 47 | ], false)->run(); |
48 | 48 | |
49 | - foreach (static::STORE as $name) { |
|
49 | + foreach (static::STORE as $name){ |
|
50 | 50 | $this->storage->store($name); |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | 54 | public function tearDown(): void |
55 | 55 | { |
56 | - foreach (static::STORE as $name) { |
|
56 | + foreach (static::STORE as $name){ |
|
57 | 57 | $this->storage->restore($name); |
58 | 58 | } |
59 | 59 | } |
@@ -35,7 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | public function setUp(): void |
37 | 37 | { |
38 | - if (!\class_exists(Kernel::class)) { |
|
38 | + if (!\class_exists(Kernel::class)) |
|
39 | + { |
|
39 | 40 | $this->markTestSkipped('A "spiral/framework" dependency is required to run these tests'); |
40 | 41 | } |
41 | 42 | |
@@ -46,14 +47,16 @@ discard block |
||
46 | 47 | 'cache' => sys_get_temp_dir() |
47 | 48 | ], false)->run(); |
48 | 49 | |
49 | - foreach (static::STORE as $name) { |
|
50 | + foreach (static::STORE as $name) |
|
51 | + { |
|
50 | 52 | $this->storage->store($name); |
51 | 53 | } |
52 | 54 | } |
53 | 55 | |
54 | 56 | public function tearDown(): void |
55 | 57 | { |
56 | - foreach (static::STORE as $name) { |
|
58 | + foreach (static::STORE as $name) |
|
59 | + { |
|
57 | 60 | $this->storage->restore($name); |
58 | 61 | } |
59 | 62 | } |