matthewbaggett / clamp
PHP clamp function to clamp a number between a minimum and a maximum.
Installs: 3 483
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: ^4.8
- satooshi/php-coveralls: ^2.0.0
This package is auto-updated.
Last update: 2024-12-24 07:49:28 UTC
README
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.