How about using the var_name setter logic with added isempty()? (which should be added to the setter anyway).