class Element

Element class

Properties

protected $name
protected $attributes
protected $children
protected $empty
static protected $emptyElements

Methods

__construct(string $name, array $attributes = array(), array $children = array())

Element constructor.

$this
attr(string $key, string $value, bool $append = false)

add attribute

$this
removeAttr(string $key)

remove attribute

$this
addClass(string $class)

add class

$this
removeClass(string $class)

remove class

$this
append(string|Element $el)

append child

$this
prepend(string|Element $el)

prepend child

$this
html(string $html)

set html or text to sole child

string
render()

render

string
__toString()

__toString

void
resolveAttribute(string $key)

transform attribute to array format

Details

at line 62
__construct(string $name, array $attributes = array(), array $children = array())

Element constructor.

Parameters

string $name element name
array $attributes attributes of element
array $children children of element

at line 81
$this attr(string $key, string $value, bool $append = false)

add attribute

Parameters

string $key attribute key
string $value value of attribute
bool $append whether append a value or set a value

Return Value

$this

at line 101
$this removeAttr(string $key)

remove attribute

Parameters

string $key attribute key

Return Value

$this

at line 114
$this addClass(string $class)

add class

Parameters

string $class class name

Return Value

$this

at line 129
$this removeClass(string $class)

remove class

Parameters

string $class class name

Return Value

$this

at line 146
$this append(string|Element $el)

append child

Parameters

string|Element $el child element

Return Value

$this

at line 164
$this prepend(string|Element $el)

prepend child

Parameters

string|Element $el child element

Return Value

$this

at line 179
$this html(string $html)

set html or text to sole child

Parameters

string $html html

Return Value

$this

at line 190
string render()

render

Return Value

string

at line 225
string __toString()

__toString

Return Value

string

at line 241
protected void resolveAttribute(string $key)

transform attribute to array format

Parameters

string $key attribute key

Return Value

void