laminas-filter icon indicating copy to clipboard operation
laminas-filter copied to clipboard

ToString filter missing?

Open vaclavvanik opened this issue 1 year ago • 1 comments

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?

vaclavvanik avatar Jan 17 '23 09:01 vaclavvanik

Send a patch with tests and it shall be added 👍

Ocramius avatar Jan 17 '23 09:01 Ocramius