Skip to content

Instantly share code, notes, and snippets.

@omnicolor
Created March 11, 2012 14:51
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 omnicolor/2016711 to your computer and use it in GitHub Desktop.
Save omnicolor/2016711 to your computer and use it in GitHub Desktop.
Static class example
/**
* 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