"I have a class Product with private properties $name and $price, and public methods getName(), getPrice(), and setPrice($newPrice). I want setPrice to reject negative numbers. Show me how to write that validation with a thrown exception, and explain why putting the check inside setPrice is better than trusting every caller to check before calling it."
