API Reference

Auto-gegenereerd via Reflection — blijft altijd in sync met src/.

Filter: alleAppCacheCmsDbDebugDynamicEventsFilesFormHtmlHttpImageLogMediaSecuritySessionStdlibSupportView

A

Framework\Html\A
final class

Typed wrapper voor <a> — href is verplicht.

Gebruik:
echo (new A('/contact'))->text('Neem contact op')->addClass('btn');
echo (new A('https://example.com'))->text('Extern')->external();

__construct(string $href)
7 public methods
add(\El ...$children = ?): self

Child-element als link-inhoud.

addClass(string ...$tokens = ?): self
aria(string $name, string|bool|null $value): self
attr(string $name, string|int|float|bool|null $value): self
external(): self

Opent in nieuw tabblad, zet automatisch rel="noopener noreferrer".

raw(string $html): self

Raw HTML als link-inhoud (bijv. icon + tekst).

text(string $text): self

Escaped tekst als link-label.

ClassList

Framework\Html\ClassList
final class

Een getypte lijst van CSS-klassen — nauw gemodelleerd naar de DOM classList API.

Gebruik via El::$classList:

$el->classList->add('foo', 'bar');
$el->classList->remove('bar');
$el->classList->contains('foo'); // true
$el->classList->toggle('open');
$el->classList->replace('old', 'new');
$el->classList->item(0); // 'foo'
count($el->classList); // 1
foreach ($el->classList as $cls) { ... }
(string) $el->classList; // 'foo'

Shortcuts op El zelf delegeren hiernaartoe:
$el->addClass('foo')->attr('href', '/x');

__construct(array $tokens = array ( ))
9 public methods
add(string ...$tokens = ?): self

Voeg één of meer klassen toe.
Strings met spaties worden gesplitst (bijv. vanuit HTML-attribuut parsing).
Duplicaten worden overgeslagen.

contains(string $token): bool

Geeft true als $token aanwezig is.

count(): int
getIterator(): ArrayIterator
item(int $index): ?string

Geeft het token op positie $index (0-based), of null als buiten bereik.

remove(string ...$tokens = ?): self

Verwijder één of meer klassen.
Geen fout als de class niet aanwezig is.

replace(string $old, string $new): bool

Vervang $old door $new. Geeft true als de vervanging geslaagd is.

$el->classList->replace('btn-primary', 'btn-secondary');

toArray(): array

Geeft alle tokens terug als array.

toggle(string $token, ?bool $force = NULL): self

Voeg toe als afwezig, verwijder als aanwezig.

$el->classList->toggle('open');
$el->classList->toggle('active', $isActive); // force aan/uit

El

Framework\Html\El
final class

Schone, strikte HTML element builder — referentie-implementatie voor nieuwe code.

Bewuste keuzes:
- El::make() heeft geen content-parameter. Tekst via ->text(), raw HTML via ->raw().
- add() accepteert alleen NodeInterface — geen verborgen raw strings.
- final: niet bedoeld om te extenden. Typed elementen (Img, A, ...) wrappen El.
- Geen ArrayObject, geen magic properties, geen deprecated API's.
- classList en style zijn volwaardige objecten, nauw gemodelleerd naar de DOM.

Gebruik:
$card = El::make('div', ['class' => 'card'])
->add(El::make('h2')->text($titel))
->add(El::make('p')->text($omschrijving));

24 public methods
add(\NodeInterface ...$children = ?): self

Voeg één of meer child-nodes toe (El, Img, A, of elke andere NodeInterface).

addClass(string ...$tokens = ?): self
aria(string $name, string|bool|null $value): self

Stel aria-{name} in. null verwijdert het attribuut.

attr(array|string $name, string|int|float|bool|null $value = NULL): self

Stel één of meer attributen in.

->attr('href', '/home')
->attr('disabled', true) // boolean attribuut
->attr('hidden', false) // weglaten
->attr(['href' => '/x', 'target' => '_blank']) // bulk

false/null = attribuut weglaten.
true = boolean attribuut (aanwezig zonder waarde, bijv. disabled).

childAt(int $index): ?self
children(): \ElCollection

Directe element-children — tekst-nodes en fragmenten uitgesloten.

data(string $name, string|int|null $value): self

Stel data-{name} in. null verwijdert het attribuut.

find(string $selector): \ElCollection

Alle descendants die matchen (depth-first).
Ondersteunde selectors: tag, .class, #id, [attr], combinaties (div.card#main[data-x])

first(string $selector): ?self

Eerste descendant die matcht — short-circuit.

static fragment(): self

Fragment — geen wrapper-tag, alleen children.

static fromHtml(string $html): self

Parseer een raw HTML-string naar een fragment met El-children.
Vereist PHP 8.4 (\Dom\HTMLDocument).

getAttr(string $name): ?string

Geeft de string-waarde van $name, of null als het attribuut afwezig is.
Boolean attributen (disabled, required, ...) geven altijd null — gebruik
hasAttr() om aanwezigheid te testen, isBoolAttr() om het type te bepalen.

hasAttr(string $name): bool

Geeft true als het attribuut aanwezig is (zowel string- als boolean-attributen).

hasClass(string $token): bool
isBoolAttr(string $name): bool

Geeft true als het attribuut een boolean attribuut is (aanwezig zonder waarde).

static make(string $nodeName, array $attrs = array ( )): self

Maak een element. Geen content-parameter — gebruik ->text() of ->raw().

matches(string $selector): bool

Geeft true als dit element zelf overeenkomt met $selector.

raw(string $html): self

Voeg raw/trusted HTML toe — NIET escaped.
Naam is bewust expliciet zodat de keuze zichtbaar is in code-reviews.
Gebruik nooit met user input.

removeAttr(string $name): self
removeClass(string ...$tokens = ?): self
removeStyle(string $property): self
setStyle(string $property, string $value): self

Stel één inline CSS-property in. Accepteert camelCase én kebab-case.

text(string $text): self

Voeg escaped tekst toe — veilig voor user input, XSS-proof.

toggleClass(string $token, ?bool $force = NULL): self

ElCollection

Framework\Html\ElCollection
final class

Getypte, fluent collectie van El-elementen.

Geretourneerd door El::find() en El::children().

$frag->find('.card')
->each(fn(El $el) => $el->addClass('active'));

$frag->find('a')->attr('target', '_blank'); // bulk via __call

count($frag->find('li'));
$frag->find('li')[2];
foreach ($frag->find('p') as $p) { ... }

__construct(array $items = array ( ))
12 public methods
count(): int
each(Closure $callback): self

Roep $callback aan voor elk element — geeft $this terug voor chaining.

$collection->each(fn(El $el) => $el->addClass('active'));

filter(Closure|string $test): self

Filter op callback of CSS-selector — geeft nieuwe ElCollection terug.

$collection->filter('.active')
$collection->filter(fn(El $el) => $el->hasAttr('data-id'))

first(): ?\El

Eerste element, of null als de collectie leeg is.

getIterator(): ArrayIterator
isEmpty(): bool

Geeft true als de collectie leeg is.

last(): ?\El

Laatste element, of null als de collectie leeg is.

map(Closure $callback): array

Map naar een nieuwe array (geen ElCollection — resultaat kan van alles zijn).

$hrefs = $collection->map(fn(El $el) => $el->getAttr('href'));

offsetExists(?mixed $offset): bool
offsetGet(?mixed $offset): ?\El
offsetSet(?mixed $offset, ?mixed $value): void
offsetUnset(?mixed $offset): void

Img

Framework\Html\Img
final class

Typed wrapper voor <img> — src is verplicht, alt expliciet.

Voordelen ten opzichte van El::make('img', ['src' => $src]):
- src is required op type-niveau (geen vergeten, geen typo)
- alt expliciet meedenken (toegankelijkheid)
- width/height fluent en typed (int, geen string-soup)
- IDE-autocompletion zonder attrs-array te kennen

Gebruik:
echo new Img('/images/logo.png', alt: 'Multiminded logo')
->width(200)
->height(60)
->addClass('logo');

// Decoratief beeld (alt leeg per WAI-ARIA spec):
echo new Img('/images/bg.jpg');

__construct(string $src, string $alt = '')
5 public methods
addClass(string ...$tokens = ?): self
attr(string $name, string|int|float|bool|null $value): self
height(int $height): self
loading(string $value): self
width(int $width): self

NodeInterface

Framework\Html\NodeInterface
interface

Contract voor alles wat als HTML gerenderd kan worden.

Implementaties:
- El — algemene element builder
- Img — <img> met verplichte src
- A — <a> met verplichte href
- (toekomstige typed elements)

Door NodeInterface te gebruiken als parameter-type in El::add() kunnen
typed wrappers naast El-instanties worden toegevoegd aan een boom,
zonder dat El zijn final-status verliest.

StyleDeclaration

Framework\Html\StyleDeclaration
final class

Inline CSS style declaration — gemodelleerd naar de DOM CSSStyleDeclaration API.

Gebruik via El::$style:

$el->style->set('color', 'red');
$el->style->set('fontSize', '16px'); // camelCase → kebab-case
$el->style->get('color'); // 'red'
$el->style->has('color'); // true
$el->style->remove('color');
(string) $el->style; // 'font-size: 16px'

Shortcuts op El zelf voor fluent chaining:
$el->style('color', 'red')->style('margin', '0');
$el->removeStyle('color');

__construct(array $properties = array ( ))
8 public methods
count(): int
static fromString(string $css): self
get(string $property): ?string

Geeft de waarde van $property terug, of null als afwezig.

getIterator(): ArrayIterator
has(string $property): bool

Geeft true als de property aanwezig is.

properties(): array

Geeft alle property-namen (kebab-case) terug.

remove(string $property): self

Verwijder een CSS-property.

set(string $property, string $value): self

Stel een CSS-property in. Accepteert camelCase én kebab-case.
Lege waarde verwijdert de property.