I'm trying to make an generic interface for my service classes. I'm having trouble with a two class making use of the interface. They share a methode called create. The create methode excepts three parameters. I want it to make it so that the third parameter is optional so that both classes can work with it.
interface ServiceInterface{
public static function create($var1, $var2, $thisOneIsOptional);
}
class ServiceObject1 implements ServiceInterface{
public static function create($url, $server){
//....
}
}
class ServiceObject2 implements ServiceInterface{
public static function create($methode, $url, $id){
//....
}
}
$idbut the other does, it should still be required. It's then up to the service to just ignore it.staticmethods are… odd anyway. Coding against an interface means you can substitute objects for other objects. However, static methods are always called on a specific class, which cannot be injected/replaced. So… why an interface in the first place?