setRaw($raw); } public static function create($value): ?Colour { $colour = is_int($value) ? $value : (is_string($value) && ctype_digit($value) ? (int)$value : -1); return $colour < 0 || $colour > 0xFFFFFF ? null : new static($colour); } public function getRaw(): int { return $this->raw; } public function setRaw(int $raw): self { $this->raw = $raw & 0xFFFFFF; return $this; } public function getHex(): string { return str_pad(dechex($this->raw), 6, '0', STR_PAD_LEFT); } }