Created
June 21, 2012 13:48
-
-
Save tobiassjosten/2965814 to your computer and use it in GitHub Desktop.
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
function addition(NumbersInterface $numbers) { | |
// We know for sure that we can access $numbers->number1, $numbers->number2 | |
// and $numbers->number2. This function can now do its one thing without | |
// being burdened with validation. | |
// http://en.wikipedia.org/wiki/Single_responsibility_principle | |
// http://en.wikipedia.org/wiki/Design_by_contract | |
} | |
interface NumbersInterface { | |
public $number1; | |
public $number2; | |
public $number3; | |
} | |
class Number implements fooInterface { | |
public $number1 = 1; | |
public $number2 = 2; | |
public $number3 = 3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment