Вход Регистрация
Файл: vendor/intervention/image/src/Traits/CanConvertRange.php
Строк: 50
<?php

declare(strict_types=1);

namespace 
InterventionImageTraits;

use 
DivisionByZeroError;
use 
InterventionImageExceptionsRuntimeException;

trait 
CanConvertRange
{
    
/**
     * Convert input in range (min) to (max) to the corresponding value
     * in target range (targetMin) to (targetMax).
     *
     * @throws RuntimeException
     */
    
public static function convertRange(
        
float|int $input,
        
float|int $min,
        
float|int $max,
        
float|int $targetMin,
        
float|int $targetMax,
    ): 
float {
        try {
            return (((
$input $min) * ($targetMax $targetMin)) / ($max $min)) + $targetMin;
        } catch (
DivisionByZeroError) {
            throw new 
RuntimeException('Division by zero');
        }
    }
}
Онлайн: 1
Реклама