function validateSwitch($state) { $switches = [1, 2, 3, 4]; $switchNumber = $switches[array_rand($switches)]; // pick a random switch $message = unserialize(VALID_SMS_MESSAGE); $message["S{$switchNumber}"] = $state; $validator = new SMSValidator($message); return $validator->validateSwitch($switchNumber); }