Passed
Push — master ( 21ea66...db5c4e )
by Kirill
02:53
created
src/Encrypter/src/Encrypter.php 1 patch
Braces   +25 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,9 +37,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
80 89
     {
81 90
         $packed = json_encode($data);
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
 block discarded – undo
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);
104
-        } catch (\Throwable $e) {
117
+        }
118
+        catch (\Throwable $e)
119
+        {
105 120
             throw new DecryptException($e->getMessage(), $e->getCode(), $e);
106 121
         }
107 122
     }
Please login to merge, or discard this patch.
src/Encrypter/src/EncrypterFactory.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,9 +40,12 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function generateKey(): string
42 42
     {
43
-        try {
43
+        try
44
+        {
44 45
             return Key::createNewRandomKey()->saveToAsciiSafeString();
45
-        } catch (CryptoException $e) {
46
+        }
47
+        catch (CryptoException $e)
48
+        {
46 49
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
47 50
         }
48 51
     }
@@ -52,9 +55,12 @@  discard block
 block discarded – undo
52 55
      */
53 56
     public function getKey(): string
54 57
     {
55
-        try {
58
+        try
59
+        {
56 60
             Key::loadFromAsciiSafeString($this->config->getKey());
57
-        } catch (CryptoException $e) {
61
+        }
62
+        catch (CryptoException $e)
63
+        {
58 64
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
59 65
         }
60 66
 
Please login to merge, or discard this patch.