Created
September 16, 2019 21:22
-
-
Save jordanbrauer/2b60c896e344a78ae2112c255de5caac to your computer and use it in GitHub Desktop.
determine if a value is within range
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
/** | |
* Determine if a numeric value is within range | |
* | |
* @return bool | |
*/ | |
function between($subject, $min, $max): bool { | |
if (!is_numeric($subject) { | |
throw new LogicException; | |
} | |
return $subject >= $min and $subject <= $max; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment