Skip to content

Class designed to find percentage of a value based on start and end points (with these points being lower and upper limits).

Notifications You must be signed in to change notification settings

tei187/range-based-percentage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

RangeBasedPercentage


RangeBasedPercentage is a utility helping to calculate the percentage of a number in given range. Examples:

  • for a range of 2-6, 4 is 50%
  • for a range of 20-40, 25 is 25%
  • for a range of 31-152, 63 is 26.446280991736%
  • and so on...

How to use?

Standard

$calculator = new tei187\RangeBasedPercentage(5, 29);  // initiate object with range 5-29
echo $calculator->getPercentage(18); // get for 18, echoes "54.166666666667"

Method chaining

$calculator = new tei187\RangeBasedPercentage;  // initiate object

echo $calculator->setRange(5, 29)->getPercentage(18); // echoes "54.16667"
echo $calculator->setRange(5, 11)->setRound(2)->getPercentage(9); // echoes "66.67"

Requirements

  • PHP >= 7.3

Author

About

Class designed to find percentage of a value based on start and end points (with these points being lower and upper limits).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages