Given a selector and a declaration list, creates the corresponding ruleset.
Parameters
$selectorstringrequired- CSS selector.
$declarationsarrayrequired- List of declarations.
Source
protected static function to_ruleset( $selector, $declarations ) {
if ( empty( $declarations ) ) {
return '';
}
$declaration_block = array_reduce(
$declarations,
static function ( $carry, $element ) {
$value = $element['value'];
if ( is_numeric( $value ) ) {
$value = (string) $value;
}
if ( ! is_string( $value ) ) {
return $carry;
}
return $carry .= $element['name'] . ': ' . $value . ';';
},
''
);
return $selector . '{' . $declaration_block . '}';
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.