Skip to content

Instantly share code, notes, and snippets.

@omnicolor
Created March 11, 2012 14:51
Show Gist options
  • 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