PHP Class HtmlObject\Traits\Tag

Inheritance: extends HtmlObject\Traits\TreeObject
Exibir arquivo Open project: anahkiasen/html-object Class Usage Examples

Public Properties

Property Type Description
$config The base configuration inherited by classes.

Protected Properties

Property Type Description
$attributes The object's attribute.
$element The element name.
$injectedProperties A list of class properties to be added to attributes.
$isOpened Whether the current tag is opened or not.
$isSelfClosing Whether the element is self closing.
$value The object's value.

Public Methods

Method Description
__call ( string $method, array $parameters ) Dynamically set attributes.
__get ( string $item ) : mixed Get an attribute or a child.
__set ( string $attribute, string $value ) Dynamically set an attribute.
__toString ( ) : string | null Render on string conversion.
addClass ( string $class ) Add one or more classes to the current field.
close ( ) : string | null Close the Tag.
getAttribute ( string $attribute ) : mixed Get an attribute.
getAttributes ( ) : array Get all attributes.
getContent ( ) : string Returns the Tag's content.
getValue ( ) : string | null Get the value.
isOpened ( ) : boolean Check if the tag is opened.
open ( ) : string | null Opens the Tag.
openOn ( $onChildren ) : string Open the tag tree on a particular child.
removeAttribute ( string $attribute ) Remove an attribute.
removeClass ( string $classes ) Remove one or more classes to the current field.
render ( ) : string | null Default rendering method.
replaceAttributes ( array $attributes ) Replace all attributes with the provided array.
setAttribute ( string $attribute, string | null $value = null ) Set an attribute.
setAttributes ( array $attributes ) Set a bunch of parameters at once.
setElement ( string $element ) Changes the Tag's element.
setValue ( string $value ) Change the object's value.
wrapValue ( string $tag ) Wrap the value in a tag.
wrapWith ( string | HtmlObject\Element $element, $name = null ) : HtmlObject\Element Wrap the Element in another element.

Protected Methods

Method Description
getTagCloser ( ) : string Get the preferred way to close a tag.
injectProperties ( ) : array Return an array of protected properties to bind as attributes.
renderChildren ( ) : string Get all the children as a string.
setTag ( string $element, string | null $value = null, array $attributes = [] ) Set up a new tag.

Method Details

__call() public method

Dynamically set attributes.
public __call ( string $method, array $parameters )
$method string An attribute
$parameters array Its value(s)

__get() public method

Get an attribute or a child.
public __get ( string $item ) : mixed
$item string The desired child/attribute
return mixed

__set() public method

Dynamically set an attribute.
public __set ( string $attribute, string $value )
$attribute string The attribute
$value string Its value

__toString() public method

Render on string conversion.
public __toString ( ) : string | null
return string | null

addClass() public method

Add one or more classes to the current field.
public addClass ( string $class )
$class string The class(es) to add

close() public method

Close the Tag.
public close ( ) : string | null
return string | null

getAttribute() public method

Get an attribute.
public getAttribute ( string $attribute ) : mixed
$attribute string
return mixed

getAttributes() public method

Get all attributes.
public getAttributes ( ) : array
return array

getContent() public method

Returns the Tag's content.
public getContent ( ) : string
return string

getTagCloser() protected method

Get the preferred way to close a tag.
protected getTagCloser ( ) : string
return string

getValue() public method

Get the value.
public getValue ( ) : string | null
return string | null

injectProperties() protected method

Return an array of protected properties to bind as attributes.
protected injectProperties ( ) : array
return array

isOpened() public method

Check if the tag is opened.
public isOpened ( ) : boolean
return boolean

open() public method

Opens the Tag.
public open ( ) : string | null
return string | null

openOn() public method

Open the tag tree on a particular child.
public openOn ( $onChildren ) : string
return string

removeAttribute() public method

Remove an attribute.
public removeAttribute ( string $attribute )
$attribute string

removeClass() public method

Remove one or more classes to the current field.
public removeClass ( string $classes )
$classes string The class(es) to remove

render() public method

Default rendering method.
public render ( ) : string | null
return string | null

renderChildren() protected method

Get all the children as a string.
protected renderChildren ( ) : string
return string

replaceAttributes() public method

Replace all attributes with the provided array.
public replaceAttributes ( array $attributes )
$attributes array The attributes to replace with

setAttribute() public method

Set an attribute.
public setAttribute ( string $attribute, string | null $value = null )
$attribute string An attribute
$value string | null Its value

setAttributes() public method

Set a bunch of parameters at once.
public setAttributes ( array $attributes )
$attributes array The attributes to add to the existing ones

setElement() public method

Changes the Tag's element.
public setElement ( string $element )
$element string

setTag() protected method

Set up a new tag.
protected setTag ( string $element, string | null $value = null, array $attributes = [] )
$element string Its element
$value string | null Its value
$attributes array Its attributes

setValue() public method

Change the object's value.
public setValue ( string $value )
$value string

wrapValue() public method

Wrap the value in a tag.
public wrapValue ( string $tag )
$tag string The tag

wrapWith() public method

Wrap the Element in another element.
public wrapWith ( string | HtmlObject\Element $element, $name = null ) : HtmlObject\Element
$element string | HtmlObject\Element The element's tag
return HtmlObject\Element

Property Details

$attributes protected_oe property

The object's attribute.
protected $attributes

$config public_oe static_oe property

The base configuration inherited by classes.
public static $config

$element protected_oe property

The element name.
protected $element

$injectedProperties protected_oe property

A list of class properties to be added to attributes.
protected $injectedProperties

$isOpened protected_oe property

Whether the current tag is opened or not.
protected $isOpened

$isSelfClosing protected_oe property

Whether the element is self closing.
protected $isSelfClosing

$value protected_oe property

The object's value.
protected $value