Skip to content

Commit 5e53f06

Browse files
committed
refactor: cs fix
1 parent 55ed3a7 commit 5e53f06

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

system/Config/BaseConfig.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ public function __construct()
133133
if ($this instanceof Encryption) {
134134
if ($property === 'key') {
135135
$this->{$property} = $this->parseEncryptionKey($this->{$property});
136-
} else if ($property === 'previousKeysFallbackEnabled') {
136+
} elseif ($property === 'previousKeysFallbackEnabled') {
137137
// previousKeysFallbackEnabled must be boolean
138138
$this->{$property} = (bool) $this->{$property};
139-
} else if ($property === 'previousKeys') {
139+
} elseif ($property === 'previousKeys') {
140140
// previousKeys must be an array
141141
if (is_string($this->{$property})) {
142-
$this->{$property} = array_map(fn($item) => $this->parseEncryptionKey($item), explode(',', $this->{$property}));
142+
$this->{$property} = array_map(fn ($item) => $this->parseEncryptionKey($item), explode(',', $this->{$property}));
143143
}
144144
}
145145
}
@@ -150,7 +150,8 @@ protected function parseEncryptionKey(string $key): string
150150
{
151151
if (str_starts_with($key, 'hex2bin:')) {
152152
return hex2bin(substr($key, 8));
153-
} elseif (str_starts_with($key, 'base64:')) {
153+
}
154+
if (str_starts_with($key, 'base64:')) {
154155
return base64_decode(substr($key, 7), true);
155156
}
156157

system/Encryption/Encryption.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ class Encryption
5555

5656
/**
5757
* Whether to fall back to previous keys when decryption fails.
58-
*
59-
* @var bool
6058
*/
6159
protected bool $previousKeysFallbackEnabled = false;
6260

6361
/**
6462
* List of previous keys for fallback decryption.
6563
*
66-
* @var string[]
64+
* @var list<string>
6765
*/
6866
protected array $previousKeys = [];
6967

@@ -105,11 +103,11 @@ public function __construct(?EncryptionConfig $config = null)
105103
{
106104
$config ??= new EncryptionConfig();
107105

108-
$this->key = $config->key;
106+
$this->key = $config->key;
109107
$this->previousKeysFallbackEnabled = $config->previousKeysFallbackEnabled;
110-
$this->previousKeys = $config->previousKeys;
111-
$this->driver = $config->driver;
112-
$this->digest = $config->digest ?? 'SHA512';
108+
$this->previousKeys = $config->previousKeys;
109+
$this->driver = $config->driver;
110+
$this->digest = $config->digest ?? 'SHA512';
113111

114112
$this->handlers = [
115113
'OpenSSL' => extension_loaded('openssl'),
@@ -132,11 +130,11 @@ public function __construct(?EncryptionConfig $config = null)
132130
public function initialize(?EncryptionConfig $config = null)
133131
{
134132
if ($config instanceof EncryptionConfig) {
135-
$this->key = $config->key;
133+
$this->key = $config->key;
136134
$this->previousKeysFallbackEnabled = $config->previousKeysFallbackEnabled ?? false;
137-
$this->previousKeys = $config->previousKeys ?? [];
138-
$this->driver = $config->driver;
139-
$this->digest = $config->digest ?? 'SHA512';
135+
$this->previousKeys = $config->previousKeys ?? [];
136+
$this->driver = $config->driver;
137+
$this->digest = $config->digest ?? 'SHA512';
140138
}
141139

142140
if (empty($this->driver)) {

system/Encryption/Handlers/OpenSSLHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,13 @@ class OpenSSLHandler extends BaseHandler
5757

5858
/**
5959
* Whether to fall back to previous keys when decryption fails.
60-
*
61-
* @var bool
6260
*/
6361
protected bool $previousKeysFallbackEnabled = false;
6462

6563
/**
6664
* List of previous keys for fallback decryption.
6765
*
68-
* @var string[]
66+
* @var list<string>
6967
*/
7068
protected array $previousKeys = [];
7169

@@ -174,6 +172,7 @@ public function decrypt($data, #[SensitiveParameter] $params = null)
174172
* @param string $key
175173
*
176174
* @return false|string
175+
*
177176
* @throws EncryptionException
178177
*/
179178
protected function decryptWithKey($data, #[SensitiveParameter] $key)

0 commit comments

Comments
 (0)