PHP Clamp function. Simple.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2018-02-07 14:50:03 +00:00
.idea A tour de force in unneccessary testing 2018-02-07 12:33:37 +00:00
src A tour de force in unneccessary testing 2018-02-07 12:33:37 +00:00
tests A tour de force in unneccessary testing 2018-02-07 12:33:37 +00:00
.coveralls.yml coveralls 2018-02-07 14:30:51 +00:00
.gitignore A tour de force in unneccessary testing 2018-02-07 12:33:37 +00:00
.travis.yml coveralls 2018-02-07 14:47:41 +00:00
composer.json coveralls 2018-02-07 14:27:21 +00:00
LICENSE Initial commit 2018-02-07 12:14:22 +00:00
phpunit.xml.dist coveralls 2018-02-07 14:47:41 +00:00
README.md Add coveralls coverage badge. 2018-02-07 14:50:03 +00:00

Clamp() for PHP

PHP mathematical "Clamp" function. It clamps a variable between two numbers. Simple.

Build Status Coverage Status

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.