CssColors

Registry of standard CSS named colors.

Constants

public const array COLORS

Map of lowercase CSS color names to their 6-digit hex values.

Methods

all

static
public static function all(): array

Get all CSS named colors as name => hex pairs.

parse

static
public static function parse(string $name): SrgbColor

Parse a named color into an sRGB color instance.

Parameters
NameTypeDefault
$name string -

tryHex

static
public static function tryHex(string $name): string

Attempt to get the hex code for a named color.

Parameters
NameTypeDefault
$name string -

tryParse

static
public static function tryParse(string $name): SrgbColor

Attempt to parse a named color into an sRGB color instance.

Parameters
NameTypeDefault
$name string -