Created
March 11, 2012 14:51
-
-
Save omnicolor/2016711 to your computer and use it in GitHub Desktop.
Static class example
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
/** | |
* Static calculator class. | |
* | |
* There's no way to dependency inject this for | |
* mocking it out while testing. | |
*/ | |
class Calculator { | |
private function __construct() {} | |
public static function add($a, $b) { | |
return $a + $b; | |
} | |
public static function multiply($a, $b) { | |
return $a * $b; | |
} | |
} | |
/** | |
* Instance calculator class. | |
*/ | |
class Calculator { | |
public function add($a, $b) { | |
return $a + $b; | |
} | |
public function multiply($a, $b) { | |
return $a * $b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment