File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 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
4141 return $ filter ;
4242 }
4343
44+ public static function snakeCaseFilter (): callable
45+ {
46+ return self ::normalizeFilter (
47+ new Filter \Word \CamelCaseToUnderscore (),
48+ new Filter \StringToLower ()
49+ );
50+ }
51+
4452 /**
4553 * Returns a filter for valid class names e.g. AddBuilding
4654 *
Original file line number Diff line number Diff line change @@ -25,6 +25,17 @@ public function providerForLabel(): Generator
2525 yield 'html ' => ['Add Building<hr id="null"><div style="text-align: left;">- buildingId: string</div><div style="text-align: left;">- name: string</div> ' ];
2626 }
2727
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+
2839 /**
2940 * @test
3041 * @dataProvider providerForLabel
You can’t perform that action at this time.
0 commit comments