Documentations › mmo.client › php › scs Value MMO\client\scs · 1 symbol · generated 30 Sep 2026
A compile-time Simple CSS value.
class MMO\client\scs\Value
implements Stringable Namespace MMO\client\scsImplements 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 RAW pre-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) static Convert 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) static 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). Raw($css) static render($quote) RenderNumber($number) static Render 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 const BOOLEAN = 'boolean' const IDENT = 'ident' const LIST = 'list' const MAP = 'map' const NIL = 'null' const NUMBER = 'number' pre-rendered css: var(--x), calc(...), rgba(0, 0, 0, .5)
const RAW = 'raw' const STRING = 'string' Properties3 readonly string $kind Type string readonly string $meta Type string readonly mixed $value Type mixed Methods20 static function Bool(bool $value): static function equals(MMO\client\scs\Value $other): bool $other Value returns bool true 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"
Convert a php value returned by an authorized php function (PhpFunctionRegistry ) into an scs value.
static function FromPhp(mixed $value, mixed $origin = null): static $value mixed $origin = null mixed the object reporting an unsupported type returns static throws when php returns something scs cannot represent (ex: an object with no adapter)
static function Ident(string $value): static function is(string $kind): bool function isTruthy(): bool returns bool everything is truthy except false and null (a 0 or an empty string is truthy, as in css)
static function ListOf(array $items, string $separator = ' '): static static function Map(array $entries): static static function Nil(): static static function Number(float $value, string $unit = ''): static function numeric(): float returns float the numeric value (0 when the value is not a number)
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 static function Raw(string $css): static function render(bool $quote = true): string $quote = true bool false to drop the quotes of a string (interpolation and selector context) returns string the value as css
Value::Number(1.50, 'rem')->render(); // '1.5rem'
Render a number the way css expects it: no trailing zeros, no scientific notation.
static function RenderNumber(float $number): string Value::RenderNumber(16.0); // '16'
static function Str(string $value, string $quote = '"'): static function toPhp(): mixed returns mixed the value as plain php, ready to be passed to an authorized php function
Value::Number(16, 'px')->toPhp(); // '16px'
function unit(): string returns string the unit of a number ('' when unitless or not a number)
function __construct(string $kind, mixed $value = null, string $meta = '') function __toString(): string