Skip to content

Instantly share code, notes, and snippets.

@ninjapanzer
Last active November 17, 2016 04:18
Show Gist options
  • Save ninjapanzer/c69c8da79f3d42e8bea872f713a454d1 to your computer and use it in GitHub Desktop.
Save ninjapanzer/c69c8da79f3d42e8bea872f713a454d1 to your computer and use it in GitHub Desktop.
static method usage
public class Butt{
private $string = '';
public static function ha($some_string)
{
$instance = new self($some_string);
return $instance->addHa();
}
public function __construct($some_string)
{
$this->string = $some_string;
}
public function addHa()
{
return $this->string . 'HA';
}
}
# I could use this two ways
(new Butt('funny '))->addHa();
# or
(Butt::ha('funny '));
# if I always end up calling ha then this is a bit shorter. Its trivial but fun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment