I've recently tried to learn more about OOP, but I'm just not sure about the following.
Is it bad practice to call other classes in the construct like so:
class Main{
function __construct(){
$this->db = new DatabaseConnection();
$this->rp = new ResponseHandler();
}
public function SelectUser( $user_id ){
...
$this->db->query('...') // `query` is a method in DataBaseConnection
...
return $this->rp->msg('...'); // `msg` is a method in ResponseHandler
}
In my eyes it seems like an easy and nice way to do this, but I don't know if this is actually the/a correct way of doing OOP.