PHP Clamp function. Simple.
- PHP 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .idea | ||
| src | ||
| tests | ||
| .coveralls.yml | ||
| .gitignore | ||
| .travis.yml | ||
| composer.json | ||
| LICENSE | ||
| phpunit.xml.dist | ||
| README.md | ||
Clamp() for PHP
PHP mathematical "Clamp" function. It clamps a variable between two numbers. Simple.
Usage:
$value = clamp(
$min, // The minimum you will accept
$max, // The maximum you can take
$value // The value you wish to clamp
);
Why?
I got sick of writing what should be a core PHP function into a Util class, only to discover other people populating that util class with other nonsense that really shouldn't be in a Util class.