I want to restrict the values that someone can assign to a variable in my function call. For e.g. say my function is
function myFunction ($carType, $isOld , $something)
{
//do what is required
}
I want that I should be able to restrict $carType, $isOld have only certain values, say from given arrays:
$carTypeValues = array ("car1", "car2", "car3");
$isOldValues = array (true,false);
I am aware that I can restrict the parameter variable to be of a certain class type.
I have tried to find a way to do this, but I am not able to find anything that addresses exactly what I want. I know I can check the value once I actually execute the function call, however I am looking for something that will allow the user to preferably be able to use selectors like:
myFunction (carType::car1, isOld::car2 , $something);
I am not sure, this maybe:
myFunction (carType.car1, isOld.car2 , $something);
Thanks for reading this