Вход Регистрация
Файл: vendor/intervention/gif/src/Blocks/Color.php
Строк: 89
<?php

declare(strict_types=1);

namespace 
InterventionGifBlocks;

use 
InterventionGifAbstractEntity;
use 
InterventionGifExceptionsInvalidArgumentException;

class 
Color extends AbstractEntity
{
    
/**
     * Create new instance.
     *
     * @throws InvalidArgumentException
     */
    
public function __construct(
        protected 
int $r 0,
        protected 
int $g 0,
        protected 
int $b 0
    
) {
        if (
$r || $r 255) {
            throw new 
InvalidArgumentException('Color channel red must be in range 0 to 255');
        }

        if (
$g || $g 255) {
            throw new 
InvalidArgumentException('Color channel green must be in range 0 to 255');
        }

        if (
$b || $b 255) {
            throw new 
InvalidArgumentException('Color channel blue must be in range 0 to 255');
        }
    }

    
/**
     * Get red value.
     */
    
public function red(): int
    
{
        return 
$this->r;
    }

    
/**
     * Set red value.
     */
    
public function setRed(int $value): self
    
{
        
$this->$value;

        return 
$this;
    }

    
/**
     * Get green value.
     */
    
public function green(): int
    
{
        return 
$this->g;
    }

    
/**
     * Set green value.
     */
    
public function setGreen(int $value): self
    
{
        
$this->$value;

        return 
$this;
    }

    
/**
     * Get blue value.
     */
    
public function blue(): int
    
{
        return 
$this->b;
    }

    
/**
     * Set blue value.
     */
    
public function setBlue(int $value): self
    
{
        
$this->$value;

        return 
$this;
    }

    
/**
     * Return hash value of current color.
     */
    
public function hash(): string
    
{
        return 
md5(strval($this->$this->$this->b));
    }
}
Онлайн: 1
Реклама