Documentation

HtmlElement
in package
implements Stringable

FinalYes

Table of Contents

Interfaces

Stringable

Properties

$attributes  : array<string, string|bool>
$contents  : Stringable|array<string|int, Stringable>|string
$selfClosing  : bool
$tagName  : string

Methods

__construct()  : mixed
__toString()  : string
getAllAttributes()  : array<string, string|bool>
getAttribute()  : string|bool|null
getContents()  : Stringable|array<string|int, Stringable>|string
getTagName()  : string
setAttribute()  : self
setContents()  : $this
Sets the inner contents of the tag (must be pre-escaped if needed)
getContentsAsString()  : string

Properties

$attributes

private array<string, string|bool> $attributes = []

$selfClosing

private bool $selfClosing
Tags
psalm-readonly

$tagName

private string $tagName
Tags
psalm-readonly

Methods

__construct()

public __construct(string $tagName[, array<string, string|array<string|int, string>|bool> $attributes = [] ][, Stringable|array<string|int, Stringable>|string|null $contents = '' ][, bool $selfClosing = false ]) : mixed
Parameters
$tagName : string

Name of the HTML tag

$attributes : array<string, string|array<string|int, string>|bool> = []

Array of attributes (values should be unescaped)

$contents : Stringable|array<string|int, Stringable>|string|null = ''

Inner contents, pre-escaped if needed

$selfClosing : bool = false

Whether the tag is self-closing

__toString()

public __toString() : string
Tags
psalm-immutable
Return values
string

getAllAttributes()

public getAllAttributes() : array<string, string|bool>
Tags
psalm-immutable
Return values
array<string, string|bool>

getAttribute()

public getAttribute(string $key) : string|bool|null
Parameters
$key : string
Tags
psalm-immutable
Return values
string|bool|null

getTagName()

public getTagName() : string
Tags
psalm-immutable
Return values
string

setAttribute()

public setAttribute(string $key[, string|array<string|int, string>|bool $value = true ]) : self
Parameters
$key : string
$value : string|array<string|int, string>|bool = true
Return values
self

setContents()

Sets the inner contents of the tag (must be pre-escaped if needed)

public setContents(Stringable|array<string|int, Stringable>|string $contents) : $this
Parameters
$contents : Stringable|array<string|int, Stringable>|string
Return values
$this

getContentsAsString()

private getContentsAsString() : string
Tags
psalm-immutable
Return values
string

        
On this page

Search results