Skip to content

Commit 95b16e1

Browse files
committed
Support separator slash - close #18
1 parent a868728 commit 95b16e1

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/Filter/NormalizeLabel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function __invoke(string $value): string
2929
// Strip multi-spaces and tabs with a single space
3030
$normalizedName = \preg_replace(['/\s{2,}/', '/[\t\n]/'], ' ', $normalizedName);
3131

32-
return \trim($normalizedName);
32+
return \trim(\trim($normalizedName), '/');
3333
}
3434
}

src/FilterFactory.php

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public static function snakeCaseFilter(): callable
4949
new Filter\StringToLower(),
5050
new Filter\Word\SeparatorToSeparator(' ', '_'),
5151
new Filter\Word\SeparatorToSeparator('-', '_'),
52+
new Filter\Word\SeparatorToSeparator('/', '_'),
5253
);
5354
}
5455

@@ -65,6 +66,7 @@ public static function camelCaseFilter(): callable
6566
new Filter\StringToLower(),
6667
new Filter\Word\UnderscoreToCamelCase(),
6768
new Filter\Word\SeparatorToSeparator(' ', '-'),
69+
new Filter\Word\SeparatorToSeparator('/', '-'),
6870
new Filter\Word\DashToCamelCase()
6971
)
7072
);
@@ -83,6 +85,7 @@ public static function pascalCaseFilter(): callable
8385
new Filter\StringToLower(),
8486
new Filter\Word\UnderscoreToCamelCase(),
8587
new Filter\Word\SeparatorToSeparator(' ', '-'),
88+
new Filter\Word\SeparatorToSeparator('/', '-'),
8689
new Filter\Word\DashToCamelCase()
8790
)
8891
);
@@ -109,6 +112,7 @@ public static function constantNameFilter(): callable
109112
new Filter\Word\CamelCaseToUnderscore(),
110113
new Filter\Word\SeparatorToSeparator(' ', '_'),
111114
new Filter\Word\SeparatorToSeparator('-', '_'),
115+
new Filter\Word\SeparatorToSeparator('/', '_'),
112116
new Filter\StringToUpper()
113117
);
114118
}

tests/FilterFactoryTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public function providerForLabel(): Generator
2727
yield 'add-building' => ['add-building'];
2828
yield 'addBuilding' => ['addBuilding'];
2929
yield 'AddBuilding' => ['AddBuilding'];
30+
yield 'Add/Building' => ['Add/Building'];
31+
yield '/Add/Building/' => ['/Add/Building/'];
3032
yield ' Add Building ' => [' Add Building '];
3133
yield 'Add building ' => ['Add building '];
3234
yield 'Add BUILDING ' => ['Add BUILDING '];

0 commit comments

Comments
 (0)