Former US President Barack Obama has spoken out against President Donald Trump’s ban on immigration from seven Muslim-majority countries.