Table of contents
Namespace: Com\Tecnick\Color
interface ColorParserInterface
Source: src/ColorParserInterface.php:38
Parses a color string into a color model.
Implemented by Web.
Methods
getColorObj()
Parse the input color string and return the corresponding color object.
public getColorObj(string $color): ?Model
Parameters:
$color(string): String containing web color definition
Returns: ?Model
Throws:
- Exception: if the color cannot be parsed
Source: src/ColorParserInterface.php:47
getHexFromName()
Get the color hexadecimal hash code from name.
public getHexFromName(string $name): string
Parameters:
$name(string): Name of the color to search (e.g.: ’turquoise')
Returns: string: color hexadecimal code (e.g.: ‘40e0d0ff’)
Throws:
- Exception: if the color is not found
Source: src/ColorParserInterface.php:65
getNameFromHex()
Get the color name from a hexadecimal hash.
public getNameFromHex(string $hex): string
Parameters:
$hex(string): hexadecimal color hash (i.e. #RRGGBBAA)
Returns: string
Throws:
- Exception: if the color is not found
Source: src/ColorParserInterface.php:74
tryGetColorObj()
Parse the input color string, returning null instead of raising.
public tryGetColorObj(string $color): ?Model
Parameters:
$color(string): String containing web color definition
Returns: ?Model
Source: src/ColorParserInterface.php:54