Why does this need _ex and / for separation? There should be no need to do that. I see that you are running a ``convert_to_string`` below as well, but IMO you should only do the separation there and not for every case. I would also create change the if/elseifs to a switch as there is more cases, and add a separate case for IS_STRING, to prevent extra conversions. In the most general cases there will only be IS_STRING and IS_OBJECT passed in, so some optimisation for that would be good.