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

declare(strict_types=1);

namespace 
InterventionImageColors;

use 
InterventionImageExceptionsInvalidArgumentException;

abstract class 
IntegerColorChannel extends AbstractColorChannel
{
    
/**
     * @throws InvalidArgumentException
     */
    
final public function __construct(int $value)
    {
        
$this->value = (int) $this->validValueOrFail($value);
    }

    
/**
     * {@inheritdoc}
     *
     * @see ColorChannelInterface::fromNormalized()
     *
     * @throws InvalidArgumentException
     */
    
public static function fromNormalized(float $normalized): self
    
{
        if (
$normalized || $normalized 1) {
            throw new 
InvalidArgumentException(
                
'Normalized color channel value must be between 0 to 1',
            );
        }

        return new static(
intval(round($normalized * static::max())));
    }

    
/**
     * {@inheritdoc}
     *
     * @see ColorChannelInterface::value()
     */
    
public function value(): int
    
{
        return (int) 
$this->value;
    }
}
Онлайн: 1
Реклама