Skip to content

Commit a58396c

Browse files
committed
applied code review suggestion
1 parent 2ef60c9 commit a58396c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Commands/Generators/NewShieldOauthGenerator.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function run(array $params): int
117117

118118
return 1;
119119
}
120+
120121
// @TODO execute() is deprecated in CI v4.3.0.
121122
$this->execute($params); // @phpstan-ignore-line suppress deprecated error.
122123

@@ -136,20 +137,21 @@ private function updateConfig($className): int
136137
return 1;
137138
}
138139

139-
// Add the code
140-
$codeKey = strtolower(str_replace('OAuth', '', $className));
141-
$codeName = ucfirst(str_replace('OAuth', '', $className));
142-
$code = "'{$codeKey}' => [
143-
'client_id' => 'Get it from {$codeName}',
144-
'client_secret' => 'Get it from {$codeName}',
140+
// Create the new config items to be added
141+
$oauthKey = strtolower(str_replace('OAuth', '', $className));
142+
$oauthName = ucfirst(str_replace('OAuth', '', $className));
143+
$code = "'{$oauthKey}' => [
144+
'client_id' => 'Get it from {$oauthName}',
145+
'client_secret' => 'Get it from {$oauthName}',
145146
146147
'allow_login' => true,
147148
],";
148149

149-
// Add helper setup
150+
// Setup the process of adding the code to the config file
150151
$pattern = '/(' . preg_quote('public array $oauthConfigs = [', '/') . ')/u';
151152
$replace = '$1' . "\n " . $code;
152153

154+
// Add the code
153155
$this->add($file, $code, $pattern, $replace);
154156

155157
return 0;

0 commit comments

Comments
 (0)