Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use static function to call internal function

Instead of doing this

  $p = new PurchasePodcast;
  $p->handle();

This feels better

  PurchasePodcast::perform();
class PurchasePodcast
{
  public static function perform()
  {
    return (new static)->handle();
  }
  
  private function handle()
  {
    // ...
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment