@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function __construct(string $key) |
| 31 | 31 | { |
| 32 | - try { |
|
| 32 | + try{ |
|
| 33 | 33 | $this->key = Key::loadFromAsciiSafeString($key); |
| 34 | - } catch (CryptoException $e) { |
|
| 34 | + }catch (CryptoException $e){ |
|
| 35 | 35 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | public function withKey(string $key): EncrypterInterface |
| 40 | 40 | { |
| 41 | 41 | $encrypter = clone $this; |
| 42 | - try { |
|
| 42 | + try{ |
|
| 43 | 43 | $encrypter->key = Key::loadFromAsciiSafeString($key); |
| 44 | - } catch (CryptoException $e) { |
|
| 44 | + }catch (CryptoException $e){ |
|
| 45 | 45 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function getKey(): string |
| 52 | 52 | { |
| 53 | - try { |
|
| 53 | + try{ |
|
| 54 | 54 | return $this->key->saveToAsciiSafeString(); |
| 55 | - } catch (EnvironmentIsBrokenException $e) { |
|
| 55 | + }catch (EnvironmentIsBrokenException $e){ |
|
| 56 | 56 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $packed = \json_encode($data); |
| 66 | 66 | |
| 67 | - try { |
|
| 67 | + try{ |
|
| 68 | 68 | return \base64_encode(Crypto::Encrypt($packed, $this->key)); |
| 69 | - } catch (\Throwable $e) { |
|
| 70 | - throw new EncryptException($e->getMessage(), (int) $e->getCode(), $e); |
|
| 69 | + }catch (\Throwable $e){ |
|
| 70 | + throw new EncryptException($e->getMessage(), (int)$e->getCode(), $e); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function decrypt(string $payload): mixed |
| 78 | 78 | { |
| 79 | - try { |
|
| 79 | + try{ |
|
| 80 | 80 | $result = Crypto::Decrypt( |
| 81 | 81 | \base64_decode($payload), |
| 82 | 82 | $this->key |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | 85 | return \json_decode($result, true); |
| 86 | - } catch (\Throwable $e) { |
|
| 87 | - throw new DecryptException($e->getMessage(), (int) $e->getCode(), $e); |
|
| 86 | + }catch (\Throwable $e){ |
|
| 87 | + throw new DecryptException($e->getMessage(), (int)$e->getCode(), $e); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -29,9 +29,12 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function __construct(string $key) |
| 31 | 31 | { |
| 32 | - try { |
|
| 32 | + try |
|
| 33 | + { |
|
| 33 | 34 | $this->key = Key::loadFromAsciiSafeString($key); |
| 34 | - } catch (CryptoException $e) { |
|
| 35 | + } |
|
| 36 | + catch (CryptoException $e) |
|
| 37 | + { |
|
| 35 | 38 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 36 | 39 | } |
| 37 | 40 | } |
@@ -39,9 +42,12 @@ discard block |
||
| 39 | 42 | public function withKey(string $key): EncrypterInterface |
| 40 | 43 | { |
| 41 | 44 | $encrypter = clone $this; |
| 42 | - try { |
|
| 45 | + try |
|
| 46 | + { |
|
| 43 | 47 | $encrypter->key = Key::loadFromAsciiSafeString($key); |
| 44 | - } catch (CryptoException $e) { |
|
| 48 | + } |
|
| 49 | + catch (CryptoException $e) |
|
| 50 | + { |
|
| 45 | 51 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 46 | 52 | } |
| 47 | 53 | |
@@ -50,9 +56,12 @@ discard block |
||
| 50 | 56 | |
| 51 | 57 | public function getKey(): string |
| 52 | 58 | { |
| 53 | - try { |
|
| 59 | + try |
|
| 60 | + { |
|
| 54 | 61 | return $this->key->saveToAsciiSafeString(); |
| 55 | - } catch (EnvironmentIsBrokenException $e) { |
|
| 62 | + } |
|
| 63 | + catch (EnvironmentIsBrokenException $e) |
|
| 64 | + { |
|
| 56 | 65 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
| 57 | 66 | } |
| 58 | 67 | } |
@@ -64,9 +73,12 @@ discard block |
||
| 64 | 73 | { |
| 65 | 74 | $packed = \json_encode($data); |
| 66 | 75 | |
| 67 | - try { |
|
| 76 | + try |
|
| 77 | + { |
|
| 68 | 78 | return \base64_encode(Crypto::Encrypt($packed, $this->key)); |
| 69 | - } catch (\Throwable $e) { |
|
| 79 | + } |
|
| 80 | + catch (\Throwable $e) |
|
| 81 | + { |
|
| 70 | 82 | throw new EncryptException($e->getMessage(), (int) $e->getCode(), $e); |
| 71 | 83 | } |
| 72 | 84 | } |
@@ -76,14 +88,17 @@ discard block |
||
| 76 | 88 | */ |
| 77 | 89 | public function decrypt(string $payload): mixed |
| 78 | 90 | { |
| 79 | - try { |
|
| 91 | + try |
|
| 92 | + { |
|
| 80 | 93 | $result = Crypto::Decrypt( |
| 81 | 94 | \base64_decode($payload), |
| 82 | 95 | $this->key |
| 83 | 96 | ); |
| 84 | 97 | |
| 85 | 98 | return \json_decode($result, true); |
| 86 | - } catch (\Throwable $e) { |
|
| 99 | + } |
|
| 100 | + catch (\Throwable $e) |
|
| 101 | + { |
|
| 87 | 102 | throw new DecryptException($e->getMessage(), (int) $e->getCode(), $e); |
| 88 | 103 | } |
| 89 | 104 | } |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function __construct( |
| 10 | 10 | public readonly string $some |
| 11 | - ) { |
|
| 11 | + ){ |
|
| 12 | 12 | } |
| 13 | 13 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $response = new Response($code); |
| 34 | 34 | $response = $response->withStatus($code, $reasonPhrase); |
| 35 | 35 | |
| 36 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 36 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
| 37 | 37 | $response = $response->withAddedHeader($header, $value); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -33,7 +33,8 @@ |
||
| 33 | 33 | $response = new Response($code); |
| 34 | 34 | $response = $response->withStatus($code, $reasonPhrase); |
| 35 | 35 | |
| 36 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 36 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
| 37 | + { |
|
| 37 | 38 | $response = $response->withAddedHeader($header, $value); |
| 38 | 39 | } |
| 39 | 40 | |
@@ -10,6 +10,6 @@ |
||
| 10 | 10 | { |
| 11 | 11 | public function __construct( |
| 12 | 12 | public readonly ServerRequestInterface $request |
| 13 | - ) { |
|
| 13 | + ){ |
|
| 14 | 14 | } |
| 15 | 15 | } |
@@ -10,6 +10,6 @@ |
||
| 10 | 10 | { |
| 11 | 11 | public function __construct( |
| 12 | 12 | public readonly ServerRequestInterface $request |
| 13 | - ) { |
|
| 13 | + ){ |
|
| 14 | 14 | } |
| 15 | 15 | } |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function __construct( |
| 10 | 10 | public readonly string $key, |
| 11 | - ) { |
|
| 11 | + ){ |
|
| 12 | 12 | } |
| 13 | 13 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $response = new Response($code); |
| 34 | 34 | $response = $response->withStatus($code, $reasonPhrase); |
| 35 | 35 | |
| 36 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 36 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
| 37 | 37 | $response = $response->withAddedHeader($header, $value); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -33,7 +33,8 @@ |
||
| 33 | 33 | $response = new Response($code); |
| 34 | 34 | $response = $response->withStatus($code, $reasonPhrase); |
| 35 | 35 | |
| 36 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 36 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
| 37 | + { |
|
| 37 | 38 | $response = $response->withAddedHeader($header, $value); |
| 38 | 39 | } |
| 39 | 40 | |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $response = new Response($code); |
| 34 | 34 | $response = $response->withStatus($code, $reasonPhrase); |
| 35 | 35 | |
| 36 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 36 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
| 37 | 37 | $response = $response->withAddedHeader($header, $value); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -33,7 +33,8 @@ |
||
| 33 | 33 | $response = new Response($code); |
| 34 | 34 | $response = $response->withStatus($code, $reasonPhrase); |
| 35 | 35 | |
| 36 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 36 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
| 37 | + { |
|
| 37 | 38 | $response = $response->withAddedHeader($header, $value); |
| 38 | 39 | } |
| 39 | 40 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | { |
| 17 | 17 | public function __construct( |
| 18 | 18 | private readonly Tokenizer $tokenizer |
| 19 | - ) { |
|
| 19 | + ){ |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |