Recipe 7.12. Calling Methods on an Object Returned by Another Method
You need to call a method on an object returned by another method.
Call the second method directly from the first:
$orange = $fruit->get('citrus')->peel();
PHP is smart enough to first call $fruit->get('citrus') and then invoke the peel( ) method on what's returned.
This is an improvement over PHP 4, where you needed to use a temporary variable:
$orange = $fruit->get('citrus'); $orange->peel();
Another victory for PHP 5!