I do have an Interface called Jsonable.
interface Jsonabe{
public function toJson();
}
And I do have two classes implementing the interface.
class facebookTransformer implements Jsonable{
protected $facebookHandler;
public function __construct(){
$this->facebookHandler = new FacebookHandler();
}
public function toJson(){
}
}
Second class:
class googleTransformer implements Jsonable{
protected $googleHandler;
public function __construct(){
$this->googleHandler = new GoogleHandler();
}
public function toJson(){
}
}
Now with the implemented interface I know that all new classes will adhere to the interface. My question is can I somehow force all the classes implementing interface to define the property also and initalize it through constructor ? Or is it okay if I add a constructor in the interface ?
I want to make sure that all the other classes will have a $handler
property.