Skip to content

Commit 57057f8

Browse files
authored
Merge pull request #11 from open-code-modeling/0.1.x-merge-up-into-0.2.x_5fc918124cc192.82611642
Merge release 0.1.1 into 0.2.x
2 parents e59093d + 8a27411 commit 57057f8

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ All notable changes to this project will be documented in this file, in reverse
2424

2525
- Nothing.
2626

27+
## 0.1.1 - 2020-12-03
28+
29+
30+
-----
31+
32+
### Release Notes for [0.1.1](https://github.com/open-code-modeling/php-filter/milestone/2)
33+
34+
0.1.x bugfix release (patch)
35+
36+
### 0.1.1
37+
38+
- Total issues resolved: **1**
39+
- Total pull requests resolved: **0**
40+
- Total contributors: **1**
41+
42+
#### bug
43+
44+
- [10: Method name filter and upper letters issue](https://github.com/open-code-modeling/php-filter/issues/10) thanks to @sandrokeil
45+
2746
## 0.1.0 - 2020-11-30
2847

2948

src/Filter/UpperToLower.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/**
4+
* @see https://github.com/open-code-modeling/php-filter for the canonical source repository
5+
* @copyright https://github.com/open-code-modeling/php-filter/blob/master/COPYRIGHT.md
6+
* @license https://github.com/open-code-modeling/php-filter/blob/master/LICENSE.md MIT License
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace OpenCodeModeling\Filter\Filter;
12+
13+
final class UpperToLower extends AbstractFilter
14+
{
15+
public function __invoke(string $value): string
16+
{
17+
$value = ($this->filter)($value);
18+
19+
if (1 === \preg_match('/^[A-Z]+$/', $value)) {
20+
return \strtolower($value);
21+
}
22+
23+
return $value;
24+
}
25+
}

src/FilterFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use OpenCodeModeling\Filter\Filter\LowerCaseFirst;
1717
use OpenCodeModeling\Filter\Filter\NormalizeLabel;
1818
use OpenCodeModeling\Filter\Filter\UpperCaseFirst;
19+
use OpenCodeModeling\Filter\Filter\UpperToLower;
1920

2021
final class FilterFactory
2122
{
@@ -93,7 +94,7 @@ public static function propertyNameFilter(): callable
9394
*/
9495
public static function methodNameFilter(): callable
9596
{
96-
return new LowerCaseFirst(self::normalizeFilter());
97+
return new LowerCaseFirst(self::normalizeFilter(new UpperToLower()));
9798
}
9899

99100
/**

tests/FilterFactoryTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ public function it_filters_method_name(string $label): void
3636
$this->assertSame('addBuilding', ($filter)($label));
3737
}
3838

39+
/**
40+
* @test
41+
*/
42+
public function it_filters_method_name_with_only_upper_letters(): void
43+
{
44+
$filter = FilterFactory::methodNameFilter();
45+
$this->assertSame('ny', ($filter)('NY'));
46+
}
47+
3948
/**
4049
* @test
4150
* @dataProvider providerForLabel

0 commit comments

Comments
 (0)