No browser lookup
PHPColor does not find an element, traverse ancestors, match selectors, calculate the cascade, or inspect computed styles.
Supply one foreground color explicitly and resolve the CSS keyword to a concrete PHPColor value.
currentColor
var(--brand)
--brand: #806eae
SrgbColor
The context stores currentColor as var(--brand). PHPColor follows that additional lookup and returns the concrete sRGB color.
The value may be a concrete color or a resolvable string. The context remains immutable after construction.
<?php
use PhpColor\Color\Css\CssColor;
use PhpColor\Color\Css\CssContext;
$variables = ['--brand' => '#806eae'];
$context = CssContext::light($variables, 'var(--brand)');
$expression = CssColor::currentColor();
$color = CssColor::resolve($expression, $context);
echo $color->toHex(); // #806eae
use PhpColor\Color\Css\CssColor;
use PhpColor\Color\Css\CssContext;
$variables = ['--brand' => '#806eae'];
$context = CssContext::light($variables, 'var(--brand)');
$expression = CssColor::currentColor();
$color = CssColor::resolve($expression, $context);
echo $color->toHex(); // #806eae
PHPColor resolves only the foreground value stored in CssContext. It does not discover that value in a rendered document.
PHPColor does not find an element, traverse ancestors, match selectors, calculate the cascade, or inspect computed styles.
Without a current foreground, non-strict resolution retains currentColor. Strict resolution throws. A supplied but unresolved string remains deferred.