Playing with Scrutinizer.
Scrutinizer seems not to recognise the is_string() check, I'm going to try the 'instanceof' check.