2023-04-15 19:17:40 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2023-08-14 15:15:05 +00:00
|
|
|
|
namespace Helper;
|
2023-04-15 19:17:40 +00:00
|
|
|
|
|
2023-08-14 15:15:05 +00:00
|
|
|
|
class Comparsion
|
2023-04-15 19:17:40 +00:00
|
|
|
|
{
|
2023-12-19 01:58:37 +00:00
|
|
|
|
/** Не даёт значению выйти за пределы.
|
2023-11-10 15:53:17 +00:00
|
|
|
|
* @param $value
|
|
|
|
|
* @param $minimum
|
|
|
|
|
* @param $maximum
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public static function minimax($value, $minimum, $maximum): mixed
|
2023-04-15 19:17:40 +00:00
|
|
|
|
{
|
|
|
|
|
if ($value < $minimum) {
|
|
|
|
|
$value = $minimum;
|
|
|
|
|
}
|
|
|
|
|
if ($value > $maximum) {
|
|
|
|
|
$value = $maximum;
|
|
|
|
|
}
|
|
|
|
|
return $value;
|
|
|
|
|
}
|
|
|
|
|
}
|