diff --git a/src/Str.php b/src/Str.php index 21c557623..4fb5238fd 100644 --- a/src/Str.php +++ b/src/Str.php @@ -32,13 +32,11 @@ public static function hasSuffix(string $value, string $suffix): bool } /** - * Ensures that the given string ends with the given suffix. If the string - * already contains the suffix, it's not added twice. It's case-insensitive - * (e.g. value: 'Foocommand' suffix: 'Command' -> result: 'FooCommand'). + * Ensures that the given string ends with the given suffix. */ public static function addSuffix(string $value, string $suffix): string { - return self::removeSuffix($value, $suffix).$suffix; + return $value.$suffix; } /** diff --git a/tests/GeneratorTest.php b/tests/GeneratorTest.php index 9c1c85f84..d5d131e23 100644 --- a/tests/GeneratorTest.php +++ b/tests/GeneratorTest.php @@ -100,5 +100,13 @@ public function getClassNameDetailsTests(): \Generator 'Symfony\\Bundle\\MakerBundle\\Tests\\GeneratorTest', 'Symfony\\Bundle\\MakerBundle\\Tests\\GeneratorTest', ]; + + yield 'repository_fqcn' => [ + 'Repository', + 'Repository\\', + 'Repository', + 'App\\Repository\\RepositoryRepository', + 'RepositoryRepository', + ]; } } diff --git a/tests/StrTest.php b/tests/StrTest.php index 8d7610658..228696d48 100644 --- a/tests/StrTest.php +++ b/tests/StrTest.php @@ -62,12 +62,12 @@ public function provideAddSuffix() { yield ['', '', '']; yield ['GenerateCommand', '', 'GenerateCommand']; - yield ['GenerateCommand', 'Command', 'GenerateCommand']; - yield ['GenerateCommand', 'command', 'Generatecommand']; - yield ['Generatecommand', 'Command', 'GenerateCommand']; - yield ['Generatecommand', 'command', 'Generatecommand']; - yield ['GenerateCommandCommand', 'Command', 'GenerateCommandCommand']; - yield ['GenerateCommandcommand', 'Command', 'GenerateCommandCommand']; + yield ['GenerateCommand', 'Command', 'GenerateCommandCommand']; + yield ['GenerateCommand', 'command', 'GenerateCommandcommand']; + yield ['Generatecommand', 'Command', 'GeneratecommandCommand']; + yield ['Generatecommand', 'command', 'Generatecommandcommand']; + yield ['GenerateCommandCommand', 'Command', 'GenerateCommandCommandCommand']; + yield ['GenerateCommandcommand', 'Command', 'GenerateCommandcommandCommand']; yield ['Generate', 'command', 'Generatecommand']; yield ['Generate', 'Command', 'GenerateCommand']; } @@ -95,7 +95,7 @@ public function provideAsClassName() yield ['gen-erate:Co-mman-d', '', 'GenErateCoMmanD']; yield ['generate', 'Command', 'GenerateCommand']; yield ['app:generate', 'Command', 'AppGenerateCommand']; - yield ['app:generate:command', 'Command', 'AppGenerateCommand']; + yield ['app:generate:command', 'Command', 'AppGenerateCommandCommand']; } public function provideAsTwigVariable()