Duplicate is_array check. Probably a matter of personal preference. I would switch this and do
if ( is_array( ... ) ) ...
elseif ( !is_string( ... ) ) ...