Файл: vendor/intervention/image/src/Colors/FloatColorChannel.php
Строк: 55
<?php
declare(strict_types=1);
namespace InterventionImageColors;
use InterventionImageExceptionsInvalidArgumentException;
abstract class FloatColorChannel extends AbstractColorChannel
{
/**
* @throws InvalidArgumentException
*/
final public function __construct(float $value)
{
$this->value = (float) $this->validValueOrFail($value);
}
/**
* {@inheritdoc}
*
* @see ColorChannelInterface::fromNormalized()
*
* @throws InvalidArgumentException
*/
public static function fromNormalized(float $normalized): self
{
if ($normalized < 0 || $normalized > 1) {
throw new InvalidArgumentException(
'Normalized color channel value must be between 0 to 1',
);
}
return new static(static::min() + $normalized * (static::max() - static::min()));
}
/**
* {@inheritdoc}
*
* @see ColorChannelInterface::value()
*/
public function value(): float
{
return (float) $this->value;
}
}