This is less of an issue, and more of a best practice question - I know these are subject to opinion, but I'm sure there must be a standard convention for this particular problem.
Let's say I've got two classes, Account
and Associate
.
Account
contains several methods which are useful to Associate
, and so naturally I'd extend the Account
class to Associate
.
However, an issue of course arises when I have two methods with the same name e.g. create()
.
So far to counteract this instead of extending the parent class, I've been instantiating it as a variable in the child classes __construct()
method, and then calling methods through that, e.g. $this->Account->create();
.
Is there another way, e.g. a norm for using an extended classes methods while still having a method of the same name in the child class?
Any answers would be greatly appreciated!