I would like to accomplish something like this: call the method, say “rotate”, and then “rotate” as applied differently to different types of data, for example, call the “rotate” using the screwdriver / param object uses the “turnScrewdriver method ", causing a" turn "using the" steering wheel "of the object / param, uses the method" turnSteeringWheel ", etc. - Different things are done, but both of them are called "turn".
I would like to implement this so that the calling code does not worry about type (s). In this example, the “turn” should be sufficient to “turn” the “screwdriver”, “steering wheel”, or any other that can be “turned”.
In C ++, I would do this with overloading - and C ++ would sort things based on data / signature type, but this does not work in PHP.
Any suggestions on where to start? The switch statement is obvious, but I think there should be a (more elegant) OO solution. No?
TIA
source
share