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

ToString filter missing? #98

Open
vaclavvanik opened this issue Jan 17, 2023 · 1 comment
Open

ToString filter missing? #98

vaclavvanik opened this issue Jan 17, 2023 · 1 comment

Comments

@vaclavvanik
Copy link
Contributor

vaclavvanik commented Jan 17, 2023

Feature Request

Laminas-filter component has ToFloat, ToInt and ToNull filters but ToString is missing.

Q A
New Feature yes
RFC no
BC Break no

Summary

This filter should be similar as ToInt:

class ToString extends AbstractFilter
{
    public function filter($value)
    {
        if (
            is_scalar($value)
            || $value === null
            || $value instanceof Stringable
        ) {
            return (string)  $value;
        }

        return $value;
    }
}

Your opinions?

@Ocramius
Copy link
Member

Send a patch with tests and it shall be added 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants