{{ "SIM swap detection" }} is a security feature that allows you to detect if a SIM swap attack has occurred on a phone number. A SIM swap attack happens when a malicious actor convinces someone working for a cellular phone carrier to link a user's phone number to a new SIM under their control. This can allow the attacker to receive all calls and SMS sent to the phone number, including one-time passwords (OTPs) delivered via SMS. Twilio offers a Lookup API that provides real-time authoritative data on whether the SIM linked to a mobile phone number has recently changed. With this API, you can detect SIM swap attacks before sending an OTP. The code provided in the tutorial uses PHP and Twilio's Lookup API to implement SIM swap detection. It creates a `SimSwap` class that models the sim_swap element in the response from the Lookup API, and a `LastSimSwap` class that models the last_sim_swap element. The code also defines a `DateIntervalStrategy` to hydrate the swappedPeriod property of the SimSwap object, and a `SimSwapFactory` class that creates a new SimSwap object from the sim_swap data returned by the Lookup API. Finally, the tutorial provides an example PHP script (`index.php`) that demonstrates how to use these classes to detect SIM swap attacks before sending an OTP.