Using an interface to save WordPress custom post types
A client needed three custom post types fed by three APIs. Instead of writing near-identical save functions, I defined one PHP interface as a contract and a single function to save any CPT that implements it.