I want to ask if creating a class that creates instances of self is good practice or not, for example, I have a class:
class MyClass { private $data = ""; private $children = array(); public function add() { $x = new MyClass();
That way, I can use some of the Tree functions, but is everything ok or should I do something differently?
For example, creating a parent class A , with children of class B, and using a multidimensional array in class A to store children
Can anyone suggest another way to do this?
If someone had experience with this, he could provide all the pros and cons that he noticed.
source share