Skip to content

Instantly share code, notes, and snippets.

@colin-haber
Created February 20, 2012 01:38
Show Gist options
  • Select an option

  • Save colin-haber/1867114 to your computer and use it in GitHub Desktop.

Select an option

Save colin-haber/1867114 to your computer and use it in GitHub Desktop.
Which one is better?
public function setRed($red) {
if ($red > 255) {
$red = 255;
} else if ($red < 0) {
$red = 0;
}
$this->red = $red;
}
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