Closed ramchale closed 3 weeks ago
@ramchale
Had another look at the regex - I think this is more like it: https://3v4l.org/ISIYe
Thanks I think the solution to #10 needs some discussion, so I've split that into it's own Draft PR
@ramchale
Had another look at the regex - I think this is more like it: https://3v4l.org/ISIYe
Awesome. Hadn't seen this before I created the additional draft. I'd put in my own unicode example, but your change seems to work for that as well 😄
@froschdesign Can I have your opinion on the use of str_replace
here?
https://github.com/laminas/laminas-filter/pull/186#discussion_r1814793452
I can't decide if input like 'Foo-Bar' should be filtered to 'Foo-Bar' or 'Foo---Bar' - I'm currently preferring the latter because it is consistent with 'Foo/Bar' => 'Foo-/-Bar'.
WDYT?
@froschdesign Can I have your opinion on the use of
str_replace
here?I can't decide if input like 'Foo-Bar' should be filtered to 'Foo-Bar' or 'Foo---Bar' - I'm currently preferring the latter because it is consistent with 'Foo/Bar' => 'Foo-/-Bar'.
WDYT?
A third option is to add an entry to the constructor Options (something like $this->deduplicateSeperator = $options['deduplicateSeperator'] ?? false;
) to toggle the use of the str_replace. Would also need to add this to CamelCaseToUnderscore and CamelCaseToDash as it currently stands.
A third option is to add an entry to the constructor Options (something like
$this->deduplicateSeperator = $options['deduplicateSeperator'] ?? false;
) to toggle the use of the str_replace. Would also need to add this to CamelCaseToUnderscore and CamelCaseToDash as it currently stands.
If we're doing extra options - it would be better to perhaps to add stripNonWord
and then preg_replace anything else with a single separator, so:
I'mAMuppet
becomes I-m-A-Muppet
, but at this point, we're trying to save devs from themselves - this filter is supposed to convert camelcase input, if you've not provided camelCase input then any weird output is on you, so I'm in favour of filtering With-Dashes
to With---Dashes
and removing any attempt to normalise input.
Also, remember that filter chain can be used, i.e. Trim | Alnum | CamelCaseToDash
Updated this in line with the conversation so far. Let me know if it needs further changes
@gsteel awesome, thanks. I think you solved the trickiest bit 😄
@gsteel Before the release I will check and update the documentation again.
Description
Refactoring CamelCaseToSeparator based on https://github.com/laminas/laminas-filter/issues/177