Update PHP code to make it more suitable for validator use