Index

Value

MMO\client\scs · 1 symbol · generated 30 Sep 2026

class

Value

Value.php:15

A compile-time Simple CSS value.

class MMO\client\scs\Value implements Stringable
Namespace
MMO\client\scs
Implements
Stringable
Every expression evaluates to one of these. A value knows how to render itself as css, which is the only thing the emitter ever asks of it.
Value::Number(16, 'px')->render(); // '16px' Value::Raw('var(--colors-primary)'); // a theme reference: stays dynamic at runtime

Index

BOOLEAN
IDENT
LIST
MAP
NIL
NUMBER
RAWpre-rendered css: var(--x), calc(...), rgba(0, 0, 0, .5)
STRING
kind readonly
meta readonly
value readonly
Bool($value) static
equals($other)
FromPhp($value, $origin) staticConvert a php value returned by an authorized php function (PhpFunctionRegistry) into an scs value.
Ident($value) static
is($kind)
isTruthy()
ListOf($items, $separator) static
Map($entries) static
Nil() static
Number($value, $unit) static
numeric()
Parse($value) staticRead a php string as the scs value it looks like: '16px' becomes a number with a unit, 'true' a boolean, anything else an identifier (so it is emitted verbatim).
Raw($css) static
render($quote)
RenderNumber($number) staticRender a number the way css expects it: no trailing zeros, no scientific notation.
Str($value, $quote) static
toPhp()
unit()
__construct($kind, $value, $meta)
__toString()

Constants8

BOOLEAN

const BOOLEAN = 'boolean'

IDENT

const IDENT = 'ident'

LIST

const LIST = 'list'

MAP

const MAP = 'map'

NIL

const NIL = 'null'

NUMBER

const NUMBER = 'number'

RAW

pre-rendered css: var(--x), calc(...), rgba(0, 0, 0, .5)

const RAW = 'raw'

STRING

const STRING = 'string'

Properties3

kind

readonly
readonly string $kind
Type
string

meta

readonly
readonly string $meta
Type
string

value

readonly
readonly mixed $value
Type
mixed

Methods20

equals($other)

Value.php:158
function equals(MMO\client\scs\Value $other): bool
$otherValue
returnsbooltrue when both values are equal -- numbers compare numerically (and by unit), everything else compares on its rendered, unquoted form, so $type == primary works with both primary and "primary"

FromPhp($value, $origin)

staticValue.php:55

Convert a php value returned by an authorized php function (PhpFunctionRegistry) into an scs value.

static function FromPhp(mixed $value, mixed $origin = null): static
$valuemixed
$origin = nullmixedthe object reporting an unsupported type
returnsstatic
throwswhen php returns something scs cannot represent (ex: an object with no adapter)

isTruthy()

Value.php:138
function isTruthy(): bool
returnsbooleverything is truthy except false and null (a 0 or an empty string is truthy, as in css)

ListOf($items, $separator)

staticValue.php:44
static function ListOf(array $items, string $separator = ' '): static
$itemsarray
$separator = ' 'string
returnsstatic

numeric()

Value.php:150
function numeric(): float
returnsfloatthe numeric value (0 when the value is not a number)

Parse($value)

staticValue.php:79

Read a php string as the scs value it looks like: '16px' becomes a number with a unit, 'true' a boolean, anything else an identifier (so it is emitted verbatim).

static function Parse(string $value): static
$valuestring
returnsstatic

render($quote)

Value.php:102
function render(bool $quote = true): string
$quote = trueboolfalse to drop the quotes of a string (interpolation and selector context)
returnsstringthe value as css
Value::Number(1.50, 'rem')->render(); // '1.5rem'

RenderNumber($number)

staticValue.php:120

Render a number the way css expects it: no trailing zeros, no scientific notation.

static function RenderNumber(float $number): string
$numberfloat
returnsstring
Value::RenderNumber(16.0); // '16'

toPhp()

Value.php:174
function toPhp(): mixed
returnsmixedthe value as plain php, ready to be passed to an authorized php function
Value::Number(16, 'px')->toPhp(); // '16px'

unit()

Value.php:147
function unit(): string
returnsstringthe unit of a number ('' when unitless or not a number)

__construct($kind, $value, $meta)

Value.php:26
function __construct(string $kind, mixed $value = null, string $meta = '')
$kindstring
$value = nullmixed
$meta = ''string