Skip to content

Attributes ​

php
final readonly class KMark\Attributes

The id and the CSS classes that a "{#id .class}" block sets on an element.

Source: src/Attributes.php

Methods ​

__construct() ​

php
public function __construct(string $id = '', array $classes = [])

extract() ​

php
public static function extract(string $text): array

Takes the "{#id .class}" block off the end of a text. If the braces hold anything else than names with a "#" or a ".", they stay in the text.

Returns array{string, self} the text and the attributes

fromList() ​

php
public static function fromList(string $names): self

The attributes of a list such as "#id .one .two", or null when it is not one.

merge() ​

php
public function merge(self $other): self

Keeps the first id and gathers the classes.

render() ​

php
public function render(): string

The attributes, ready to be written in a tag.

Documentation of 2.0.0 , built from f573e5f on 2.0.0 by pipeline #37507527063 on 2026-10-06.