Last active
November 17, 2016 04:18
-
-
Save ninjapanzer/c69c8da79f3d42e8bea872f713a454d1 to your computer and use it in GitHub Desktop.
static method usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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