File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ public static function normalizeFilter(callable ...$callables): callable
41
41
return $ filter ;
42
42
}
43
43
44
+ public static function snakeCaseFilter (): callable
45
+ {
46
+ return self ::normalizeFilter (
47
+ new Filter \Word \CamelCaseToUnderscore (),
48
+ new Filter \StringToLower ()
49
+ );
50
+ }
51
+
44
52
/**
45
53
* Returns a filter for valid class names e.g. AddBuilding
46
54
*
Original file line number Diff line number Diff line change @@ -25,6 +25,17 @@ public function providerForLabel(): Generator
25
25
yield 'html ' => ['Add Building<hr id="null"><div style="text-align: left;">- buildingId: string</div><div style="text-align: left;">- name: string</div> ' ];
26
26
}
27
27
28
+ /**
29
+ * @test
30
+ * @dataProvider providerForLabel
31
+ * @param string $label
32
+ */
33
+ public function it_filters_snake_case (string $ label ): void
34
+ {
35
+ $ filter = FilterFactory::snakeCaseFilter ();
36
+ $ this ->assertSame ('add_building ' , ($ filter )($ label ));
37
+ }
38
+
28
39
/**
29
40
* @test
30
41
* @dataProvider providerForLabel
You can’t perform that action at this time.
0 commit comments