@@ -11,5 +11,5 @@ |
||
11 | 11 | * @return \Closure(object $event): void |
12 | 12 | * @throws \BadMethodCallException |
13 | 13 | */ |
14 | - public function create(string|object $listener, string $method): \Closure; |
|
14 | + public function create(string | object $listener, string $method): \Closure; |
|
15 | 15 | } |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | |
10 | 10 | final class AutowireListenerFactory implements ListenerFactoryInterface |
11 | 11 | { |
12 | - public function create(string|object $listener, string $method): \Closure |
|
12 | + public function create(string | object $listener, string $method): \Closure |
|
13 | 13 | { |
14 | - if ($this->listenerShouldBeAutowired($listener, $method)) { |
|
14 | + if ($this->listenerShouldBeAutowired($listener, $method)){ |
|
15 | 15 | return static function (object $event) use ($listener, $method): void { |
16 | 16 | ContainerScope::getContainer() |
17 | 17 | ->get(InvokerInterface::class) |
@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return TClass |
32 | 32 | */ |
33 | - private static function getListener(string|object $listener): object |
|
33 | + private static function getListener(string | object $listener): object |
|
34 | 34 | { |
35 | - if (\is_object($listener)) { |
|
35 | + if (\is_object($listener)){ |
|
36 | 36 | return $listener; |
37 | 37 | } |
38 | 38 | |
39 | 39 | return ContainerScope::getContainer()->get($listener); |
40 | 40 | } |
41 | 41 | |
42 | - private function listenerShouldBeAutowired(object|string $listener, string $method): bool |
|
42 | + private function listenerShouldBeAutowired(object | string $listener, string $method): bool |
|
43 | 43 | { |
44 | - if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) { |
|
44 | + if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)){ |
|
45 | 45 | return true; |
46 | 46 | } |
47 | 47 | |
48 | - try { |
|
48 | + try{ |
|
49 | 49 | $refMethod = new \ReflectionMethod($listener, $method); |
50 | 50 | |
51 | 51 | return $refMethod->getNumberOfParameters() > 1; |
52 | - } catch (\ReflectionException $e) { |
|
52 | + }catch (\ReflectionException $e){ |
|
53 | 53 | $listener = \is_object($listener) ? $listener::class : $listener; |
54 | 54 | |
55 | 55 | throw match (true) { |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | { |
12 | 12 | public function create(string|object $listener, string $method): \Closure |
13 | 13 | { |
14 | - if ($this->listenerShouldBeAutowired($listener, $method)) { |
|
14 | + if ($this->listenerShouldBeAutowired($listener, $method)) |
|
15 | + { |
|
15 | 16 | return static function (object $event) use ($listener, $method): void { |
16 | 17 | ContainerScope::getContainer() |
17 | 18 | ->get(InvokerInterface::class) |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | */ |
33 | 34 | private static function getListener(string|object $listener): object |
34 | 35 | { |
35 | - if (\is_object($listener)) { |
|
36 | + if (\is_object($listener)) |
|
37 | + { |
|
36 | 38 | return $listener; |
37 | 39 | } |
38 | 40 | |
@@ -41,15 +43,19 @@ discard block |
||
41 | 43 | |
42 | 44 | private function listenerShouldBeAutowired(object|string $listener, string $method): bool |
43 | 45 | { |
44 | - if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) { |
|
46 | + if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) |
|
47 | + { |
|
45 | 48 | return true; |
46 | 49 | } |
47 | 50 | |
48 | - try { |
|
51 | + try |
|
52 | + { |
|
49 | 53 | $refMethod = new \ReflectionMethod($listener, $method); |
50 | 54 | |
51 | 55 | return $refMethod->getNumberOfParameters() > 1; |
52 | - } catch (\ReflectionException $e) { |
|
56 | + } |
|
57 | + catch (\ReflectionException $e) |
|
58 | + { |
|
53 | 59 | $listener = \is_object($listener) ? $listener::class : $listener; |
54 | 60 | |
55 | 61 | throw match (true) { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | { |
19 | 19 | public function __construct( |
20 | 20 | private readonly EncrypterConfig $config |
21 | - ) { |
|
21 | + ){ |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function generateKey(): string |
28 | 28 | { |
29 | - try { |
|
29 | + try{ |
|
30 | 30 | return Key::createNewRandomKey()->saveToAsciiSafeString(); |
31 | - } catch (CryptoException $e) { |
|
31 | + }catch (CryptoException $e){ |
|
32 | 32 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
36 | 36 | public function getKey(): string |
37 | 37 | { |
38 | - try { |
|
38 | + try{ |
|
39 | 39 | Key::loadFromAsciiSafeString($this->config->getKey()); |
40 | - } catch (CryptoException $e) { |
|
40 | + }catch (CryptoException $e){ |
|
41 | 41 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
42 | 42 | } |
43 | 43 |
@@ -26,18 +26,24 @@ |
||
26 | 26 | */ |
27 | 27 | public function generateKey(): string |
28 | 28 | { |
29 | - try { |
|
29 | + try |
|
30 | + { |
|
30 | 31 | return Key::createNewRandomKey()->saveToAsciiSafeString(); |
31 | - } catch (CryptoException $e) { |
|
32 | + } |
|
33 | + catch (CryptoException $e) |
|
34 | + { |
|
32 | 35 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
33 | 36 | } |
34 | 37 | } |
35 | 38 | |
36 | 39 | public function getKey(): string |
37 | 40 | { |
38 | - try { |
|
41 | + try |
|
42 | + { |
|
39 | 43 | Key::loadFromAsciiSafeString($this->config->getKey()); |
40 | - } catch (CryptoException $e) { |
|
44 | + } |
|
45 | + catch (CryptoException $e) |
|
46 | + { |
|
41 | 47 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
42 | 48 | } |
43 | 49 |
@@ -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 | } |
@@ -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 |