Passed
Push — master ( 21ea66...db5c4e )
by Kirill
02:53
created
src/Encrypter/tests/EncrypterTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
         $this->assertNotEquals('test string', $encrypted);
62 62
         $this->assertEquals('test string', $encrypter->decrypt($encrypted));
63 63
 
64
-        $encrypter->decrypt('badData.' . $encrypted);
64
+        $encrypter->decrypt('badData.'.$encrypted);
65 65
     }
66 66
 
67 67
     public function testBadKey(): void
Please login to merge, or discard this patch.
src/Encrypter/src/Encrypter.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
80 80
     {
81 81
         $packed = json_encode($data);
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
 block discarded – undo
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);
104
-        } catch (\Throwable $e) {
104
+        }catch (\Throwable $e){
105 105
             throw new DecryptException($e->getMessage(), $e->getCode(), $e);
106 106
         }
107 107
     }
Please login to merge, or discard this 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 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function generateKey(): string
42 42
     {
43
-        try {
43
+        try{
44 44
             return Key::createNewRandomKey()->saveToAsciiSafeString();
45
-        } catch (CryptoException $e) {
45
+        }catch (CryptoException $e){
46 46
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
47 47
         }
48 48
     }
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function getKey(): string
54 54
     {
55
-        try {
55
+        try{
56 56
             Key::loadFromAsciiSafeString($this->config->getKey());
57
-        } catch (CryptoException $e) {
57
+        }catch (CryptoException $e){
58 58
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
59 59
         }
60 60
 
Please login to merge, or discard this 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.