Created
February 20, 2012 01:38
-
-
Save colin-haber/1867114 to your computer and use it in GitHub Desktop.
Which one is better?
This file contains hidden or 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 function setRed($red) { | |
| if ($red > 255) { | |
| $red = 255; | |
| } else if ($red < 0) { | |
| $red = 0; | |
| } | |
| $this->red = $red; | |
| } |
This file contains hidden or 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 function setRed($red) { | |
| if ($red > 255 || $red < 0) { | |
| throw new InvalidArgumentException(); | |
| } else { | |
| $this->red = $red; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment