DEV Community

Discussion on: PHP - Elegant method call

Collapse
 
vlasales profile image
Vlastimil Pospichal • Edited

Better way:

$sendmail = new Sendmail();
$sendmail->handle($this->user);

Why? You may inject object $sendmail into another method. You may simple replace this object with $nullObject or $stubObject when you want run tests.