Skip to content

Instantly share code, notes, and snippets.

@ratiw
Last active April 13, 2016 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ratiw/011c589608833b25af9e2d4fdb5dbbe0 to your computer and use it in GitHub Desktop.
Save ratiw/011c589608833b25af9e2d4fdb5dbbe0 to your computer and use it in GitHub Desktop.
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