Skip to content

Commit a9f0920

Browse files
committed
refactor: add method check prefix
1 parent eccc0b1 commit a9f0920

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Commands/InitCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ protected function createOrUpdateConfigFile(string $fileName, string $separator,
428428

429429
$item = "{$key}{$separator}{$value}";
430430

431-
if (!empty($previousKey) && Str::before($key, '_') === Str::before($previousKey, '_')) {
431+
if (!empty($previousKey) && $this->configFileHaveSameLinePrefix($key, $previousKey)) {
432432
$lines[] = $item;
433433
} else {
434434
$lines[] = "\n{$item}";
@@ -442,6 +442,11 @@ protected function createOrUpdateConfigFile(string $fileName, string $separator,
442442
file_put_contents($fileName, $ymlSettings);
443443
}
444444

445+
protected function configFileHaveSameLinePrefix(string $key, string $previousKey): bool
446+
{
447+
return Str::before($key, '_') === Str::before($previousKey, '_');
448+
}
449+
445450
protected function loadReadmePart(string $fileName): string
446451
{
447452
$file = base_path(DIRECTORY_SEPARATOR . self::TEMPLATES_PATH . DIRECTORY_SEPARATOR . $fileName);

0 commit comments

Comments
 (0)