Apple has a feature in Settings called Silence Unknown Callers. If you routinely get a lot of spam calls then this is the feature for you.
If you receive a call from a number that is not in your contacts, iOS will silence the call, send it to voicemail, and display it on the Recents list in the phone app. Incoming calls from your contacts, numbers you recently called, and Siri Suggestions will continue to ring.
How to silence Unknown Callers
Open Settings.
Select Phone.
Select Silence Unknown Callers and turn the toggle on.
If you place an emergency call iOS will disable this feature for 24 hours incase emergency dispatchers and first responders need to contact you.