@@ -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 /**
0 commit comments