This is the same script, written in two different languages, written to demonstrate the Shadow proxy (https://github.com/twilio/shadow).
The basics of the demo are to start with the PHP script, show what it does, then move to Shadow.
Because this script picks responses deterministically, Shadow won't show any problems unless something is wrong.
Here is the Shadow config script that we're using for this demo: https://gist.github.com/kelvl/5470902