I'm working on a class to manipulate html hex color codes in php. Internally, the class treats RGB values as decimals. When I'm adding or subtracting, I never want the value to exceed 255 nor 'subceed' zero.
If course, I can do something piecemeal like
if ( $val > 255 ) {
$val = 255;
}
if ( $val < 0 ) {
$val = 0;
}
But that's verbose :P
Is there a clever, one-linish way I can get the value to stay between 0 and 255?