Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
}
}
14 changes: 7 additions & 7 deletions tests/StrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down Expand Up @@ -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()
Expand Down