diff --git a/src/SPC/util/LicenseDumper.php b/src/SPC/util/LicenseDumper.php index 4ebff36b..d5f43909 100644 --- a/src/SPC/util/LicenseDumper.php +++ b/src/SPC/util/LicenseDumper.php @@ -90,8 +90,8 @@ class LicenseDumper $licenses = [$licenses]; } - foreach ($licenses as $license) { - yield match ($license['type']) { + foreach ($licenses as $index => $license) { + yield ($license['suffix'] ?? $index) => match ($license['type']) { 'text' => $license['text'], 'file' => $this->loadSourceFile($source_name, $license['path'], Config::getSource($source_name)['path'] ?? null), default => throw new RuntimeException('source [' . $source_name . '] license type is not allowed'), diff --git a/tests/SPC/util/LicenseDumperTest.php b/tests/SPC/util/LicenseDumperTest.php index 18a31277..e1ca06c9 100644 --- a/tests/SPC/util/LicenseDumperTest.php +++ b/tests/SPC/util/LicenseDumperTest.php @@ -37,6 +37,7 @@ final class LicenseDumperTest extends TestCase 'license' => [ 'type' => 'text', 'text' => 'license', + 'suffix' => 'zend', ], ], ]; @@ -45,7 +46,7 @@ final class LicenseDumperTest extends TestCase $dumper->addLibs(['fake_lib']); $dumper->dump(self::DIRECTORY); - $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_0.txt'); + $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_zend.txt'); } public function testDumpWithMultipleLicenses(): void @@ -66,6 +67,11 @@ final class LicenseDumperTest extends TestCase 'type' => 'text', 'text' => 'license', ], + [ + 'type' => 'text', + 'text' => 'license', + 'suffix' => 'zend', + ], ], ], ]; @@ -76,5 +82,6 @@ final class LicenseDumperTest extends TestCase $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_0.txt'); $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_1.txt'); + $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_zend.txt'); } }