Skip to content

Commit 4142632

Browse files
committed
Merge remote-tracking branch 'origin/0.1.x-merge-up-into-0.2.x_60245b040bc558.02334330' into 0.2.x
# Conflicts: # CHANGELOG.md # composer.json
2 parents aa6fb84 + ba17169 commit 4142632

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

CHANGELOG.md

+19
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.2 - 2021-02-10
28+
29+
30+
-----
31+
32+
### Release Notes for [0.1.2](https://github.com/open-code-modeling/php-filter/milestone/5)
33+
34+
0.1.x bugfix release (patch)
35+
36+
### 0.1.2
37+
38+
- Total issues resolved: **1**
39+
- Total pull requests resolved: **0**
40+
- Total contributors: **1**
41+
42+
#### bug
43+
44+
- [12: Improve default filters to match more cases](https://github.com/open-code-modeling/php-filter/issues/12) thanks to @sandrokeil
45+
2746
## 0.1.1 - 2020-12-03
2847

2948

src/FilterFactory.php

+33-7
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@ final class FilterFactory
2323
/**
2424
* Returns a normalize filter for labels, names ...
2525
*
26-
* @param callable ...$callables Attached to the end of the filter chain
26+
* @param callable ...$callables Attached to the end of the filter chain
2727
* @return callable
2828
*/
2929
public static function normalizeFilter(callable ...$callables): callable
3030
{
3131
$filter = new Filter\FilterChain();
3232
$filter->attach(new NormalizeLabel());
33-
$filter->attach(new Filter\Word\SeparatorToSeparator(' ', '-'));
34-
$filter->attach(new Filter\Word\UnderscoreToCamelCase());
35-
$filter->attach(new Filter\Word\DashToCamelCase());
3633

3734
foreach ($callables as $callable) {
3835
$filter->attach($callable);
@@ -66,7 +63,15 @@ public static function pascalCaseFilter(): callable
6663
*/
6764
public static function classNameFilter(): callable
6865
{
69-
return new UpperCaseFirst(self::normalizeFilter());
66+
return new UpperCaseFirst(
67+
self::normalizeFilter(
68+
new Filter\Word\CamelCaseToUnderscore(),
69+
new Filter\StringToLower(),
70+
new Filter\Word\UnderscoreToCamelCase(),
71+
new Filter\Word\SeparatorToSeparator(' ', '-'),
72+
new Filter\Word\DashToCamelCase()
73+
)
74+
);
7075
}
7176

7277
/**
@@ -77,6 +82,8 @@ public static function classNameFilter(): callable
7782
public static function constantNameFilter(): callable
7883
{
7984
return self::normalizeFilter(
85+
new Filter\Word\SeparatorToSeparator(' ', '-'),
86+
new Filter\Word\DashToCamelCase(),
8087
new Filter\Word\CamelCaseToUnderscore(),
8188
new Filter\StringToUpper()
8289
);
@@ -90,6 +97,8 @@ public static function constantNameFilter(): callable
9097
public static function constantValueFilter(): callable
9198
{
9299
return self::normalizeFilter(
100+
new Filter\Word\SeparatorToSeparator(' ', '-'),
101+
new Filter\Word\DashToCamelCase(),
93102
new Filter\Word\CamelCaseToUnderscore(),
94103
new Filter\StringToLower()
95104
);
@@ -102,7 +111,15 @@ public static function constantValueFilter(): callable
102111
*/
103112
public static function propertyNameFilter(): callable
104113
{
105-
return new LowerCaseFirst(self::normalizeFilter());
114+
return new LowerCaseFirst(
115+
self::normalizeFilter(
116+
new Filter\Word\CamelCaseToUnderscore(),
117+
new Filter\StringToLower(),
118+
new Filter\Word\UnderscoreToCamelCase(),
119+
new Filter\Word\SeparatorToSeparator(' ', '-'),
120+
new Filter\Word\DashToCamelCase()
121+
)
122+
);
106123
}
107124

108125
/**
@@ -112,7 +129,16 @@ public static function propertyNameFilter(): callable
112129
*/
113130
public static function methodNameFilter(): callable
114131
{
115-
return new LowerCaseFirst(self::normalizeFilter(new UpperToLower()));
132+
return new LowerCaseFirst(
133+
self::normalizeFilter(
134+
new Filter\Word\CamelCaseToUnderscore(),
135+
new Filter\StringToLower(),
136+
new Filter\Word\UnderscoreToCamelCase(),
137+
new Filter\Word\SeparatorToSeparator(' ', '-'),
138+
new Filter\Word\DashToCamelCase(),
139+
new UpperToLower()
140+
)
141+
);
116142
}
117143

118144
/**

tests/FilterFactoryTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ final class FilterFactoryTest extends TestCase
2121
*/
2222
public function providerForLabel(): Generator
2323
{
24+
yield 'ADD_BUILDING' => ['ADD_BUILDING'];
2425
yield 'add building' => ['add building'];
2526
yield 'add_building' => ['add_building'];
2627
yield 'add-building' => ['add-building'];

0 commit comments

Comments
 (0)