Skip to content

Caelrik\Ui\Support ​

Arr ​

final class Caelrik\Ui\Support\Arr

Dot-notation helpers for row arrays (user.name reads $row['user']['name']).

Methods ​

get ​

php
static get(array $row, string $path): mixed

set ​

php
static set(array $row, string $path, mixed $value): void

toText ​

php
static toText(mixed $value): string

Converts a cell value to display text.

Dates ​

final class Caelrik\Ui\Support\Dates

Strict ISO 8601 date parsing for values coming from requests and databases.

Only 2026-11-05, 2026-11-05T14:30, 2026-11-05 14:30:00 and the same with seconds, fractions and a Z / +01:00 offset are accepted: PHP's relative formats ("next monday") never are.

Methods ​

parse ​

php
static parse(mixed $value, ?DateTimeZone $timeZone = null): DateTimeImmutable

isDateOnly ​

php
static isDateOnly(mixed $value): bool

EditorHtml ​

final class Caelrik\Ui\Support\EditorHtml

Server-side cleaning of rich text editor output (Field::editor()).

The browser can send any HTML, whatever the editor allows, so sanitize before storing or displaying it. The default configuration allows exactly what the Caelrik toolbars produce. Requires symfony/html-sanitizer (composer require symfony/html-sanitizer).

Methods ​

sanitize ​

php
static sanitize(string $html, ?HtmlSanitizerConfig $config = null): string

config ​

php
static config(): HtmlSanitizerConfig

Paragraphs, headings (h2-h4), bold, italic, underline, strike, lists, quotes, code, and http(s)/mailto links (forced to rel="noopener noreferrer nofollow").

Html ​

final class Caelrik\Ui\Support\Html

Minimal, escaping-by-default HTML builder used by every component.

Methods ​

escape ​

php
static escape(string|int|float|null $value): string

attributes ​

php
static attributes(array $attributes): string

Renders an attribute list. true renders a boolean attribute, null and false skip it.

tag ​

php
static tag(string $name, array $attributes = [], ?string $content = null): string

Renders an element. $content is inserted as-is: escape it before passing user data.

raw ​

php
static raw(string $html): RawHtml

Marks markup as trusted, so content-accepting components insert it unescaped.

content ​

php
static content(Stringable|string $content): string

Content for Modal and Tabs: a string is escaped text, a Stringable (a component, Html::raw(), Laravel's HtmlString, Twig's Markup) is inserted as HTML.

classes ​

php
static classes(array $classes): ?string

Joins CSS classes, dropping empty entries and duplicates.

QrMatrix ​

final class Caelrik\Ui\Support\QrMatrix

A QR code encoder (ISO/IEC 18004, model 2, versions 1 to 40): the text is encoded as one segment (numeric, alphanumeric or UTF-8 bytes, whichever is shortest) in the smallest version that holds it, with Reed-Solomon error correction and the mask of the lowest penalty. It follows the structure of Project Nayuki's QR Code generator (MIT).

php
QrMatrix::encode('https://example.com', 'M'); // list of rows of booleans (true = dark)

Constants ​

ConstantValue
LEVELS['L', 'M', 'Q', 'H']

Methods ​

encode ​

php
static encode(string $text, string $level = 'M', ?int $version = null, ?int $mask = null): array

The modules of the QR code of $text, row by row (true = dark), without the quiet zone.

  • $version: a fixed version (1 to 40); by default the smallest that holds the text
  • $mask: a fixed mask (0 to 7); by default the one of the lowest penalty
  • Throws LengthException when the text is too long for a QR code at this level

RawHtml ​

final class Caelrik\Ui\Support\RawHtml implements Stringable

Trusted HTML, inserted as-is where components accept content (Modal, Tabs). Create it with Html::raw() only for markup you control or have sanitized.

Methods ​

__construct ​

php
__construct(string $html)

Url ​

final class Caelrik\Ui\Support\Url

URLs from data, made safe for href and src.

Methods ​

safe ​

php
static safe(string $url): ?string

A relative, http or https URL, or null (javascript:, data: and other schemes are dropped).

The scheme is read as browsers read it: the letters before the first colon, when no "/", "?" or "#" comes first. PHP's parse_url() reads "javascript:0" as a host and a port, so it is not used.

Released under the MIT License.