Skip to content

Commit ef045ce

Browse files
committed
refactor: early return
1 parent 82328c4 commit ef045ce

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

system/Config/BaseConfig.php

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,27 @@ public function __construct()
8383
{
8484
static::$moduleConfig = config(Modules::class);
8585

86-
if (static::$override) {
87-
$this->registerProperties();
88-
89-
$properties = array_keys(get_object_vars($this));
90-
$prefix = static::class;
91-
$slashAt = strrpos($prefix, '\\');
92-
$shortPrefix = strtolower(substr($prefix, $slashAt === false ? 0 : $slashAt + 1));
93-
94-
foreach ($properties as $property) {
95-
$this->initEnvValue($this->{$property}, $property, $prefix, $shortPrefix);
96-
97-
if ($this instanceof Encryption && $property === 'key') {
98-
if (strpos($this->{$property}, 'hex2bin:') === 0) {
99-
// Handle hex2bin prefix
100-
$this->{$property} = hex2bin(substr($this->{$property}, 8));
101-
} elseif (strpos($this->{$property}, 'base64:') === 0) {
102-
// Handle base64 prefix
103-
$this->{$property} = base64_decode(substr($this->{$property}, 7), true);
104-
}
86+
if (! static::$override) {
87+
return;
88+
}
89+
90+
$this->registerProperties();
91+
92+
$properties = array_keys(get_object_vars($this));
93+
$prefix = static::class;
94+
$slashAt = strrpos($prefix, '\\');
95+
$shortPrefix = strtolower(substr($prefix, $slashAt === false ? 0 : $slashAt + 1));
96+
97+
foreach ($properties as $property) {
98+
$this->initEnvValue($this->{$property}, $property, $prefix, $shortPrefix);
99+
100+
if ($this instanceof Encryption && $property === 'key') {
101+
if (strpos($this->{$property}, 'hex2bin:') === 0) {
102+
// Handle hex2bin prefix
103+
$this->{$property} = hex2bin(substr($this->{$property}, 8));
104+
} elseif (strpos($this->{$property}, 'base64:') === 0) {
105+
// Handle base64 prefix
106+
$this->{$property} = base64_decode(substr($this->{$property}, 7), true);
105107
}
106108
}
107109
}

0 commit comments

Comments
 (0)