Easiest way I can think of it is:
If you explicitly rely on a connection of a specific type, pass that into the object:
PHP Code:
$con = Connection::getInstance();
$user = new User($con);
If each class can explicitly make its own connection, its aggregated by the class:
PHP Code:
class User
{
private $con;
public function __construct()
{
$this->con = Connection::getInstance();
}
}
This is more useful if Connection can be established with multiple connections. In the example of a singleton, it doesn't matter if its passed in or if its constructed within as you will always end up with the same connection. Aggregate it within the class if you want to have the ability to construct an alternate connection. I'd pass it into the class if it must rely on a specific connection (which may or may not be reused by other classes).
So if your individual class is capable of providing alternate storage instructions, I'd allow it to do so by creating it within. If it cannot provide alternate instructions, then I'd pass it as a parameter.