private static function isStringCastable($value) { return is_scalar($value) || is_object($value) && method_exists($value, '__toString'); }