@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct(string $key) |
| 39 | 39 | { |
| 40 | - try { |
|
| 40 | + try{ |
|
| 41 | 41 | $this->key = Key::loadFromAsciiSafeString($key); |
| 42 | - } catch (CryptoException $e) { |
|
| 42 | + }catch (CryptoException $e){ |
|
| 43 | 43 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | public function withKey(string $key): EncrypterInterface |
| 51 | 51 | { |
| 52 | 52 | $encrypter = clone $this; |
| 53 | - try { |
|
| 53 | + try{ |
|
| 54 | 54 | $encrypter->key = Key::loadFromAsciiSafeString($key); |
| 55 | - } catch (CryptoException $e) { |
|
| 55 | + }catch (CryptoException $e){ |
|
| 56 | 56 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function getKey(): string |
| 66 | 66 | { |
| 67 | - try { |
|
| 67 | + try{ |
|
| 68 | 68 | return $this->key->saveToAsciiSafeString(); |
| 69 | - } catch (EnvironmentIsBrokenException $e) { |
|
| 69 | + }catch (EnvironmentIsBrokenException $e){ |
|
| 70 | 70 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | $packed = json_encode($data, JSON_THROW_ON_ERROR); |
| 82 | 82 | |
| 83 | - try { |
|
| 83 | + try{ |
|
| 84 | 84 | return base64_encode(Crypto::Encrypt($packed, $this->key)); |
| 85 | - } catch (Throwable $e) { |
|
| 85 | + }catch (Throwable $e){ |
|
| 86 | 86 | throw new EncryptException($e->getMessage(), $e->getCode(), $e); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function decrypt(string $payload) |
| 96 | 96 | { |
| 97 | - try { |
|
| 97 | + try{ |
|
| 98 | 98 | $result = Crypto::Decrypt( |
| 99 | 99 | base64_decode($payload), |
| 100 | 100 | $this->key |
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | 103 | return json_decode($result, true, 512, JSON_THROW_ON_ERROR); |
| 104 | - } catch (Throwable $e) { |
|
| 104 | + }catch (Throwable $e){ |
|
| 105 | 105 | throw new DecryptException($e->getMessage(), $e->getCode(), $e); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -37,9 +37,12 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct(string $key) |
| 39 | 39 | { |
| 40 | - try { |
|
| 40 | + try |
|
| 41 | + { |
|
| 41 | 42 | $this->key = Key::loadFromAsciiSafeString($key); |
| 42 | - } catch (CryptoException $e) { |
|
| 43 | + } |
|
| 44 | + catch (CryptoException $e) |
|
| 45 | + { |
|
| 43 | 46 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 44 | 47 | } |
| 45 | 48 | } |
@@ -50,9 +53,12 @@ discard block |
||
| 50 | 53 | public function withKey(string $key): EncrypterInterface |
| 51 | 54 | { |
| 52 | 55 | $encrypter = clone $this; |
| 53 | - try { |
|
| 56 | + try |
|
| 57 | + { |
|
| 54 | 58 | $encrypter->key = Key::loadFromAsciiSafeString($key); |
| 55 | - } catch (CryptoException $e) { |
|
| 59 | + } |
|
| 60 | + catch (CryptoException $e) |
|
| 61 | + { |
|
| 56 | 62 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 57 | 63 | } |
| 58 | 64 | |
@@ -64,9 +70,12 @@ discard block |
||
| 64 | 70 | */ |
| 65 | 71 | public function getKey(): string |
| 66 | 72 | { |
| 67 | - try { |
|
| 73 | + try |
|
| 74 | + { |
|
| 68 | 75 | return $this->key->saveToAsciiSafeString(); |
| 69 | - } catch (EnvironmentIsBrokenException $e) { |
|
| 76 | + } |
|
| 77 | + catch (EnvironmentIsBrokenException $e) |
|
| 78 | + { |
|
| 70 | 79 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 71 | 80 | } |
| 72 | 81 | } |
@@ -80,9 +89,12 @@ discard block |
||
| 80 | 89 | { |
| 81 | 90 | $packed = json_encode($data, JSON_THROW_ON_ERROR); |
| 82 | 91 | |
| 83 | - try { |
|
| 92 | + try |
|
| 93 | + { |
|
| 84 | 94 | return base64_encode(Crypto::Encrypt($packed, $this->key)); |
| 85 | - } catch (Throwable $e) { |
|
| 95 | + } |
|
| 96 | + catch (Throwable $e) |
|
| 97 | + { |
|
| 86 | 98 | throw new EncryptException($e->getMessage(), $e->getCode(), $e); |
| 87 | 99 | } |
| 88 | 100 | } |
@@ -94,14 +106,17 @@ discard block |
||
| 94 | 106 | */ |
| 95 | 107 | public function decrypt(string $payload) |
| 96 | 108 | { |
| 97 | - try { |
|
| 109 | + try |
|
| 110 | + { |
|
| 98 | 111 | $result = Crypto::Decrypt( |
| 99 | 112 | base64_decode($payload), |
| 100 | 113 | $this->key |
| 101 | 114 | ); |
| 102 | 115 | |
| 103 | 116 | return json_decode($result, true, 512, JSON_THROW_ON_ERROR); |
| 104 | - } catch (Throwable $e) { |
|
| 117 | + } |
|
| 118 | + catch (Throwable $e) |
|
| 119 | + { |
|
| 105 | 120 | throw new DecryptException($e->getMessage(), $e->getCode(), $e); |
| 106 | 121 | } |
| 107 | 122 | } |
@@ -43,21 +43,21 @@ |
||
| 43 | 43 | ob_start(); |
| 44 | 44 | $__outputLevel__ = ob_get_level(); |
| 45 | 45 | |
| 46 | - try { |
|
| 46 | + try{ |
|
| 47 | 47 | ContainerScope::runScope($this->container, function () use ($data): void { |
| 48 | 48 | extract($data, EXTR_OVERWRITE); |
| 49 | 49 | // render view in context and output buffer scope, context can be accessed using $this->context |
| 50 | 50 | require $this->view->getFilename(); |
| 51 | 51 | }); |
| 52 | - } catch (Throwable $e) { |
|
| 53 | - while (ob_get_level() >= $__outputLevel__) { |
|
| 52 | + }catch (Throwable $e){ |
|
| 53 | + while (ob_get_level() >= $__outputLevel__){ |
|
| 54 | 54 | ob_end_clean(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | throw new RenderException($e); |
| 58 | - } finally { |
|
| 58 | + }finally{ |
|
| 59 | 59 | //Closing all nested buffers |
| 60 | - while (ob_get_level() > $__outputLevel__) { |
|
| 60 | + while (ob_get_level() > $__outputLevel__){ |
|
| 61 | 61 | ob_end_clean(); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -43,21 +43,28 @@ |
||
| 43 | 43 | ob_start(); |
| 44 | 44 | $__outputLevel__ = ob_get_level(); |
| 45 | 45 | |
| 46 | - try { |
|
| 46 | + try |
|
| 47 | + { |
|
| 47 | 48 | ContainerScope::runScope($this->container, function () use ($data): void { |
| 48 | 49 | extract($data, EXTR_OVERWRITE); |
| 49 | 50 | // render view in context and output buffer scope, context can be accessed using $this->context |
| 50 | 51 | require $this->view->getFilename(); |
| 51 | 52 | }); |
| 52 | - } catch (Throwable $e) { |
|
| 53 | - while (ob_get_level() >= $__outputLevel__) { |
|
| 53 | + } |
|
| 54 | + catch (Throwable $e) |
|
| 55 | + { |
|
| 56 | + while (ob_get_level() >= $__outputLevel__) |
|
| 57 | + { |
|
| 54 | 58 | ob_end_clean(); |
| 55 | 59 | } |
| 56 | 60 | |
| 57 | 61 | throw new RenderException($e); |
| 58 | - } finally { |
|
| 62 | + } |
|
| 63 | + finally |
|
| 64 | + { |
|
| 59 | 65 | //Closing all nested buffers |
| 60 | - while (ob_get_level() > $__outputLevel__) { |
|
| 66 | + while (ob_get_level() > $__outputLevel__) |
|
| 67 | + { |
|
| 61 | 68 | ob_end_clean(); |
| 62 | 69 | } |
| 63 | 70 | } |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | 'namespaces' => $config->getNamespaces(), |
| 37 | 37 | ]); |
| 38 | 38 | |
| 39 | - foreach ($this->config->getDependencies() as $dependency) { |
|
| 39 | + foreach ($this->config->getDependencies() as $dependency){ |
|
| 40 | 40 | $this->addDependency($dependency->resolve($factory)); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - foreach ($this->config->getEngines() as $engine) { |
|
| 43 | + foreach ($this->config->getEngines() as $engine){ |
|
| 44 | 44 | $this->addEngine($engine->resolve($factory)); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if ($this->config->isCacheEnabled()) { |
|
| 47 | + if ($this->config->isCacheEnabled()){ |
|
| 48 | 48 | $this->cache = new ViewCache(); |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function compile(string $path): void |
| 98 | 98 | { |
| 99 | - if ($this->cache !== null) { |
|
| 99 | + if ($this->cache !== null){ |
|
| 100 | 100 | $this->cache->resetPath($path); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | // Rotate all possible context variants and warm up cache |
| 106 | 106 | $generator = new ContextGenerator($this->context); |
| 107 | - foreach ($generator->generate() as $context) { |
|
| 107 | + foreach ($generator->generate() as $context){ |
|
| 108 | 108 | $engine->reset($path, $context); |
| 109 | 109 | $engine->compile($path, $context); |
| 110 | 110 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function reset(string $path): void |
| 117 | 117 | { |
| 118 | - if ($this->cache !== null) { |
|
| 118 | + if ($this->cache !== null){ |
|
| 119 | 119 | $this->cache->resetPath($path); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | // Rotate all possible context variants and warm up cache |
| 125 | 125 | $generator = new ContextGenerator($this->context); |
| 126 | - foreach ($generator->generate() as $context) { |
|
| 126 | + foreach ($generator->generate() as $context){ |
|
| 127 | 127 | $engine->reset($path, $context); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function get(string $path): ViewInterface |
| 138 | 138 | { |
| 139 | - if ($this->cache !== null && $this->cache->has($this->context, $path)) { |
|
| 139 | + if ($this->cache !== null && $this->cache->has($this->context, $path)){ |
|
| 140 | 140 | return $this->cache->get($this->context, $path); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $view = $this->findEngine($path)->get($path, $this->context); |
| 144 | 144 | |
| 145 | - if ($this->cache !== null) { |
|
| 145 | + if ($this->cache !== null){ |
|
| 146 | 146 | $this->cache->set($this->context, $path, $view); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | private function findEngine(string $path): EngineInterface |
| 166 | 166 | { |
| 167 | - foreach ($this->engines as $engine) { |
|
| 168 | - if ($engine->getLoader()->exists($path)) { |
|
| 167 | + foreach ($this->engines as $engine){ |
|
| 168 | + if ($engine->getLoader()->exists($path)){ |
|
| 169 | 169 | return $engine; |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -36,15 +36,18 @@ discard block |
||
| 36 | 36 | 'namespaces' => $config->getNamespaces(), |
| 37 | 37 | ]); |
| 38 | 38 | |
| 39 | - foreach ($this->config->getDependencies() as $dependency) { |
|
| 39 | + foreach ($this->config->getDependencies() as $dependency) |
|
| 40 | + { |
|
| 40 | 41 | $this->addDependency($dependency->resolve($factory)); |
| 41 | 42 | } |
| 42 | 43 | |
| 43 | - foreach ($this->config->getEngines() as $engine) { |
|
| 44 | + foreach ($this->config->getEngines() as $engine) |
|
| 45 | + { |
|
| 44 | 46 | $this->addEngine($engine->resolve($factory)); |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | - if ($this->config->isCacheEnabled()) { |
|
| 49 | + if ($this->config->isCacheEnabled()) |
|
| 50 | + { |
|
| 48 | 51 | $this->cache = new ViewCache(); |
| 49 | 52 | } |
| 50 | 53 | } |
@@ -96,7 +99,8 @@ discard block |
||
| 96 | 99 | */ |
| 97 | 100 | public function compile(string $path): void |
| 98 | 101 | { |
| 99 | - if ($this->cache !== null) { |
|
| 102 | + if ($this->cache !== null) |
|
| 103 | + { |
|
| 100 | 104 | $this->cache->resetPath($path); |
| 101 | 105 | } |
| 102 | 106 | |
@@ -104,7 +108,8 @@ discard block |
||
| 104 | 108 | |
| 105 | 109 | // Rotate all possible context variants and warm up cache |
| 106 | 110 | $generator = new ContextGenerator($this->context); |
| 107 | - foreach ($generator->generate() as $context) { |
|
| 111 | + foreach ($generator->generate() as $context) |
|
| 112 | + { |
|
| 108 | 113 | $engine->reset($path, $context); |
| 109 | 114 | $engine->compile($path, $context); |
| 110 | 115 | } |
@@ -115,7 +120,8 @@ discard block |
||
| 115 | 120 | */ |
| 116 | 121 | public function reset(string $path): void |
| 117 | 122 | { |
| 118 | - if ($this->cache !== null) { |
|
| 123 | + if ($this->cache !== null) |
|
| 124 | + { |
|
| 119 | 125 | $this->cache->resetPath($path); |
| 120 | 126 | } |
| 121 | 127 | |
@@ -123,7 +129,8 @@ discard block |
||
| 123 | 129 | |
| 124 | 130 | // Rotate all possible context variants and warm up cache |
| 125 | 131 | $generator = new ContextGenerator($this->context); |
| 126 | - foreach ($generator->generate() as $context) { |
|
| 132 | + foreach ($generator->generate() as $context) |
|
| 133 | + { |
|
| 127 | 134 | $engine->reset($path, $context); |
| 128 | 135 | } |
| 129 | 136 | } |
@@ -136,13 +143,15 @@ discard block |
||
| 136 | 143 | */ |
| 137 | 144 | public function get(string $path): ViewInterface |
| 138 | 145 | { |
| 139 | - if ($this->cache !== null && $this->cache->has($this->context, $path)) { |
|
| 146 | + if ($this->cache !== null && $this->cache->has($this->context, $path)) |
|
| 147 | + { |
|
| 140 | 148 | return $this->cache->get($this->context, $path); |
| 141 | 149 | } |
| 142 | 150 | |
| 143 | 151 | $view = $this->findEngine($path)->get($path, $this->context); |
| 144 | 152 | |
| 145 | - if ($this->cache !== null) { |
|
| 153 | + if ($this->cache !== null) |
|
| 154 | + { |
|
| 146 | 155 | $this->cache->set($this->context, $path, $view); |
| 147 | 156 | } |
| 148 | 157 | |
@@ -164,8 +173,10 @@ discard block |
||
| 164 | 173 | */ |
| 165 | 174 | private function findEngine(string $path): EngineInterface |
| 166 | 175 | { |
| 167 | - foreach ($this->engines as $engine) { |
|
| 168 | - if ($engine->getLoader()->exists($path)) { |
|
| 176 | + foreach ($this->engines as $engine) |
|
| 177 | + { |
|
| 178 | + if ($engine->getLoader()->exists($path)) |
|
| 179 | + { |
|
| 169 | 180 | return $engine; |
| 170 | 181 | } |
| 171 | 182 | } |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function handle(string $name, string $id, $payload): void |
| 47 | 47 | { |
| 48 | - if (\is_string($payload)) { |
|
| 48 | + if (\is_string($payload)){ |
|
| 49 | 49 | $payload = json_decode($payload, true, 512, JSON_THROW_ON_ERROR); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if (!\is_array($payload)) { |
|
| 52 | + if (!\is_array($payload)){ |
|
| 53 | 53 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -57,15 +57,15 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $email = $this->renderer->render($message); |
| 59 | 59 | |
| 60 | - if ($email->getFrom() === []) { |
|
| 60 | + if ($email->getFrom() === []){ |
|
| 61 | 61 | $email->from(Address::create($this->config->getFromAddress())); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $recipients = $this->getRecipients($email); |
| 65 | 65 | |
| 66 | - try { |
|
| 66 | + try{ |
|
| 67 | 67 | $this->mailer->send($email); |
| 68 | - } catch (TransportExceptionInterface $e) { |
|
| 68 | + }catch (TransportExceptionInterface $e){ |
|
| 69 | 69 | $this->getLogger()->error( |
| 70 | 70 | sprintf( |
| 71 | 71 | 'Failed to send `%s` to "%s": %s', |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
| 97 | 97 | |
| 98 | - foreach ($addresses as $address) { |
|
| 98 | + foreach ($addresses as $address){ |
|
| 99 | 99 | $emails[] = $address->toString(); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -45,11 +45,13 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function handle(string $name, string $id, $payload): void |
| 47 | 47 | { |
| 48 | - if (\is_string($payload)) { |
|
| 48 | + if (\is_string($payload)) |
|
| 49 | + { |
|
| 49 | 50 | $payload = json_decode($payload, true, 512, JSON_THROW_ON_ERROR); |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | - if (!\is_array($payload)) { |
|
| 53 | + if (!\is_array($payload)) |
|
| 54 | + { |
|
| 53 | 55 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
| 54 | 56 | } |
| 55 | 57 | |
@@ -57,15 +59,19 @@ discard block |
||
| 57 | 59 | |
| 58 | 60 | $email = $this->renderer->render($message); |
| 59 | 61 | |
| 60 | - if ($email->getFrom() === []) { |
|
| 62 | + if ($email->getFrom() === []) |
|
| 63 | + { |
|
| 61 | 64 | $email->from(Address::create($this->config->getFromAddress())); |
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | $recipients = $this->getRecipients($email); |
| 65 | 68 | |
| 66 | - try { |
|
| 69 | + try |
|
| 70 | + { |
|
| 67 | 71 | $this->mailer->send($email); |
| 68 | - } catch (TransportExceptionInterface $e) { |
|
| 72 | + } |
|
| 73 | + catch (TransportExceptionInterface $e) |
|
| 74 | + { |
|
| 69 | 75 | $this->getLogger()->error( |
| 70 | 76 | sprintf( |
| 71 | 77 | 'Failed to send `%s` to "%s": %s', |
@@ -95,7 +101,8 @@ discard block |
||
| 95 | 101 | |
| 96 | 102 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
| 97 | 103 | |
| 98 | - foreach ($addresses as $address) { |
|
| 104 | + foreach ($addresses as $address) |
|
| 105 | + { |
|
| 99 | 106 | $emails[] = $address->toString(); |
| 100 | 107 | } |
| 101 | 108 | |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | public function findDeclarations(): array |
| 46 | 46 | { |
| 47 | 47 | $result = []; |
| 48 | - foreach ($this->locator->getScopedClasses('routes') as $class) { |
|
| 49 | - foreach ($class->getMethods() as $method) { |
|
| 48 | + foreach ($this->locator->getScopedClasses('routes') as $class){ |
|
| 49 | + foreach ($class->getMethods() as $method){ |
|
| 50 | 50 | $route = $this->reader->firstFunctionMetadata($method, Route::class); |
| 51 | 51 | |
| 52 | - if ($route === null) { |
|
| 52 | + if ($route === null){ |
|
| 53 | 53 | continue; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | 'controller' => $class->getName(), |
| 60 | 60 | 'action' => $method->getName(), |
| 61 | 61 | 'group' => $route->group, |
| 62 | - 'verbs' => (array) $route->methods, |
|
| 62 | + 'verbs' => (array)$route->methods, |
|
| 63 | 63 | 'defaults' => $route->defaults, |
| 64 | - 'middleware' => (array) $route->middleware, |
|
| 64 | + 'middleware' => (array)$route->middleware, |
|
| 65 | 65 | 'priority' => $route->priority, |
| 66 | 66 | ]; |
| 67 | 67 | } |
@@ -45,11 +45,14 @@ |
||
| 45 | 45 | public function findDeclarations(): array |
| 46 | 46 | { |
| 47 | 47 | $result = []; |
| 48 | - foreach ($this->locator->getScopedClasses('routes') as $class) { |
|
| 49 | - foreach ($class->getMethods() as $method) { |
|
| 48 | + foreach ($this->locator->getScopedClasses('routes') as $class) |
|
| 49 | + { |
|
| 50 | + foreach ($class->getMethods() as $method) |
|
| 51 | + { |
|
| 50 | 52 | $route = $this->reader->firstFunctionMetadata($method, Route::class); |
| 51 | 53 | |
| 52 | - if ($route === null) { |
|
| 54 | + if ($route === null) |
|
| 55 | + { |
|
| 53 | 56 | continue; |
| 54 | 57 | } |
| 55 | 58 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $registry = $container->get(HandlerRegistryInterface::class); |
| 58 | 58 | $config = $container->get(QueueConfig::class); |
| 59 | 59 | |
| 60 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
| 60 | + foreach ($config->getRegistryHandlers() as $jobType => $handler){ |
|
| 61 | 61 | $registry->setHandler($jobType, $handler); |
| 62 | 62 | } |
| 63 | 63 | }); |
@@ -57,7 +57,8 @@ |
||
| 57 | 57 | $registry = $container->get(HandlerRegistryInterface::class); |
| 58 | 58 | $config = $container->get(QueueConfig::class); |
| 59 | 59 | |
| 60 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
| 60 | + foreach ($config->getRegistryHandlers() as $jobType => $handler) |
|
| 61 | + { |
|
| 61 | 62 | $registry->setHandler($jobType, $handler); |
| 62 | 63 | } |
| 63 | 64 | }); |
@@ -23,13 +23,13 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function getHandler(string $jobType): HandlerInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 26 | + try{ |
|
| 27 | 27 | $handler = $this->container->get($this->className($jobType)); |
| 28 | - } catch (ContainerException $e) { |
|
| 28 | + }catch (ContainerException $e){ |
|
| 29 | 29 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if (!$handler instanceof HandlerInterface) { |
|
| 32 | + if (!$handler instanceof HandlerInterface){ |
|
| 33 | 33 | throw new JobException("Unable to resolve job handler for `{$jobType}`"); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -23,13 +23,17 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function getHandler(string $jobType): HandlerInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 26 | + try |
|
| 27 | + { |
|
| 27 | 28 | $handler = $this->container->get($this->className($jobType)); |
| 28 | - } catch (ContainerException $e) { |
|
| 29 | + } |
|
| 30 | + catch (ContainerException $e) |
|
| 31 | + { |
|
| 29 | 32 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
| 30 | 33 | } |
| 31 | 34 | |
| 32 | - if (!$handler instanceof HandlerInterface) { |
|
| 35 | + if (!$handler instanceof HandlerInterface) |
|
| 36 | + { |
|
| 33 | 37 | throw new JobException("Unable to resolve job handler for `{$jobType}`"); |
| 34 | 38 | } |
| 35 | 39 | |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public function serialize(array $payload): string |
| 21 | 21 | { |
| 22 | - try { |
|
| 22 | + try{ |
|
| 23 | 23 | return serialize($payload); |
| 24 | - } catch (Throwable $e) { |
|
| 24 | + }catch (Throwable $e){ |
|
| 25 | 25 | throw new SerializationException($e->getMessage(), (int)$e->getCode(), $e); |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function deserialize(string $payload): array |
| 33 | 33 | { |
| 34 | - try { |
|
| 34 | + try{ |
|
| 35 | 35 | return (array)unserialize($payload); |
| 36 | - } catch (Throwable $e) { |
|
| 36 | + }catch (Throwable $e){ |
|
| 37 | 37 | throw new SerializationException($e->getMessage(), (int)$e->getCode(), $e); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -19,9 +19,12 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public function serialize(array $payload): string |
| 21 | 21 | { |
| 22 | - try { |
|
| 22 | + try |
|
| 23 | + { |
|
| 23 | 24 | return serialize($payload); |
| 24 | - } catch (Throwable $e) { |
|
| 25 | + } |
|
| 26 | + catch (Throwable $e) |
|
| 27 | + { |
|
| 25 | 28 | throw new SerializationException($e->getMessage(), (int)$e->getCode(), $e); |
| 26 | 29 | } |
| 27 | 30 | } |
@@ -31,9 +34,12 @@ discard block |
||
| 31 | 34 | */ |
| 32 | 35 | public function deserialize(string $payload): array |
| 33 | 36 | { |
| 34 | - try { |
|
| 37 | + try |
|
| 38 | + { |
|
| 35 | 39 | return (array)unserialize($payload); |
| 36 | - } catch (Throwable $e) { |
|
| 40 | + } |
|
| 41 | + catch (Throwable $e) |
|
| 42 | + { |
|
| 37 | 43 | throw new SerializationException($e->getMessage(), (int)$e->getCode(), $e); |
| 38 | 44 | } |
| 39 | 45 | } |
@@ -20,11 +20,11 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function handle(string $name, string $id, array $payload): void |
| 22 | 22 | { |
| 23 | - if (!isset($payload['callback'])) { |
|
| 23 | + if (!isset($payload['callback'])){ |
|
| 24 | 24 | throw new InvalidArgumentException('Payload `callback` key is required.'); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if (!$payload['callback'] instanceof Closure) { |
|
| 27 | + if (!$payload['callback'] instanceof Closure){ |
|
| 28 | 28 | throw new InvalidArgumentException('Payload `callback` key value type should be a closure.'); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -20,11 +20,13 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function handle(string $name, string $id, array $payload): void |
| 22 | 22 | { |
| 23 | - if (!isset($payload['callback'])) { |
|
| 23 | + if (!isset($payload['callback'])) |
|
| 24 | + { |
|
| 24 | 25 | throw new InvalidArgumentException('Payload `callback` key is required.'); |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | - if (!$payload['callback'] instanceof Closure) { |
|
| 28 | + if (!$payload['callback'] instanceof Closure) |
|
| 29 | + { |
|
| 28 | 30 | throw new InvalidArgumentException('Payload `callback` key value type should be a closure.'); |
| 29 | 31 | } |
| 30 | 32 | |