I am searching for the best way to call a class method from another class, without having to use Global to fetch the class instance, cus as i understand now that "Global is evil" !
Here is some code to explain it more:
class Assets{
public $assets = array();
public function add($asset){
$this->assets[] = $asset;
}
}
Now i wanna call the Assets/call method from with in here ..
$assets = new Assets;
class Form{
public function __construct(){
global $assets;
$assets->add('Form');
}
}
Is using Global in such scenario is THAT bad ? If so, what other way is considered to be the best ?
PS: I need to work with only one instance of the class; means that i don't want to create a new instance inside of the second class.