Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CamelCaseToDashFilter & numbers #10

Closed
weierophinney opened this issue Dec 31, 2019 · 3 comments · Fixed by #186
Closed

CamelCaseToDashFilter & numbers #10

weierophinney opened this issue Dec 31, 2019 · 3 comments · Fixed by #186
Assignees
Milestone

Comments

@weierophinney
Copy link
Member

Not sure if this is expected behavior but seems like a bug to me, but if you pass a string with numbers into CamelCaseToDashFilter the dash is not applied before a number, please see below for a failing unit test.

    public function testFilterSeparatesCamelCasedWordsContainingNumbersWithDashes()
    {
        $string   = 'ItIs2016';
        $filter   = new CamelCaseToDashFilter();
        $filtered = $filter($string);
        $this->assertNotEquals($string, $filtered);
        $this->assertEquals('It-Is-2016', $filtered);
    }

Originally posted by @joshhornby at zendframework/zend-filter#33

@froschdesign
Copy link
Member

froschdesign commented Sep 4, 2024

@gsteel
Do we want this behaviour for this filter?
Some code is already available: zendframework/zend-filter#45

If we look at the filter for the opposite, then it would be consistent:

$filter = new Laminas\Filter\Word\DashToCamelCase();
$value  = 'foo-bar-123';
echo $filter->filter($value); // Output: FooBar123

@gsteel
Copy link
Member

gsteel commented Sep 4, 2024

I think so - IMO ItIs2016 -> It-Is-2016 is what I'd expect the filter to do, so if it doesn't, now is a good time to fix that!

@gsteel
Copy link
Member

gsteel commented Nov 4, 2024

Closed via #186

@gsteel gsteel closed this as completed Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants