diff --git a/CHANGELOG.md b/CHANGELOG.md index 8670a19..3c71722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,25 @@ All notable changes to this project will be documented in this file, in reverse - Nothing. +## 0.1.1 - 2020-12-03 + + +----- + +### Release Notes for [0.1.1](https://github.com/open-code-modeling/php-filter/milestone/2) + +0.1.x bugfix release (patch) + +### 0.1.1 + +- Total issues resolved: **1** +- Total pull requests resolved: **0** +- Total contributors: **1** + +#### bug + + - [10: Method name filter and upper letters issue](https://github.com/open-code-modeling/php-filter/issues/10) thanks to @sandrokeil + ## 0.1.0 - 2020-11-30 diff --git a/src/Filter/UpperToLower.php b/src/Filter/UpperToLower.php new file mode 100644 index 0000000..7d40bd6 --- /dev/null +++ b/src/Filter/UpperToLower.php @@ -0,0 +1,25 @@ +filter)($value); + + if (1 === \preg_match('/^[A-Z]+$/', $value)) { + return \strtolower($value); + } + + return $value; + } +} diff --git a/src/FilterFactory.php b/src/FilterFactory.php index 2e62fc4..44c4b94 100644 --- a/src/FilterFactory.php +++ b/src/FilterFactory.php @@ -16,6 +16,7 @@ use OpenCodeModeling\Filter\Filter\LowerCaseFirst; use OpenCodeModeling\Filter\Filter\NormalizeLabel; use OpenCodeModeling\Filter\Filter\UpperCaseFirst; +use OpenCodeModeling\Filter\Filter\UpperToLower; final class FilterFactory { @@ -93,7 +94,7 @@ public static function propertyNameFilter(): callable */ public static function methodNameFilter(): callable { - return new LowerCaseFirst(self::normalizeFilter()); + return new LowerCaseFirst(self::normalizeFilter(new UpperToLower())); } /** diff --git a/tests/FilterFactoryTest.php b/tests/FilterFactoryTest.php index 59dae54..bbf45ab 100644 --- a/tests/FilterFactoryTest.php +++ b/tests/FilterFactoryTest.php @@ -36,6 +36,15 @@ public function it_filters_method_name(string $label): void $this->assertSame('addBuilding', ($filter)($label)); } + /** + * @test + */ + public function it_filters_method_name_with_only_upper_letters(): void + { + $filter = FilterFactory::methodNameFilter(); + $this->assertSame('ny', ($filter)('NY')); + } + /** * @test * @dataProvider providerForLabel