class InlineScript extends AbstractComponent implements Script

Implementation of a script tag having script code as its content

IMPORTANT:

This component contains scripting statements

Methods

__construct(string|null $code = null)

Constructor

__destruct()

Destructor

__clone()

Clones the object

string
getTagName()

Returns the tag name of the component

attributes()

Returns the attribute container attached to the component

string
identify(string|null $id = null)

Identifies the element with an unique id attribute.

cssClasses()

Returns the class attribute object

css(array|string|null $styles = null)

Sets the inline styles

style()

Returns the attribute object containing inline styles

setAttribute(string $name, mixed $value = true)

Sets an attribute name value pair

removeAttribute(string $name)

Removes given attribute if it is not locked

mixed
getAttribute(string $name)

Returns the value of a given attribute name or an empty string if attribute is not set

bool
attributeExists(string $name)

Checks if an attribute exists

addCssClass(string ...$cssClasses)

Adds the specified CSS class names

removeCssClass(string ...$cssClasses)

Removes given CSS class names

bool
hasCssClass(string ...$cssClasses)

Determines whether the given CSS class names are stored into the manager

string
getOpeningTag()

Returns opening tag with its attributes

string
contentToString()

Returns the content of the component as a string

string
getClosingTag()

Returns closing tag

string
__toString()

Gets a string representation of the object

appendJavaScript(string $code)

No description

string
getHash()

Returns the hash value

Details

at line 38
__construct(string|null $code = null)

Constructor

Parameters

string|null $code

the script code inside the script component or null for empty

in AbstractTag at line 45
__destruct()

Destructor

in AbstractTag at line 57
__clone()

Clones the object

Note: Method cannot be called directly!

in AbstractTag at line 64
string getTagName()

Returns the tag name of the component

Return Value

string

the tag name of the component

in AbstractTag at line 69
AttributeContainer attributes()

Returns the attribute container attached to the component

Return Value

AttributeContainer

the attribute manager

in AbstractTag at line 77
string identify(string|null $id = null)

Identifies the element with an unique id attribute.

Notes:

HTML id attribute is unique to every HTML-element. Therefore given id is checked for its uniqueness.

Parameters

string|null $id

a new id value is created or not

Return Value

string

in AbstractTag at line 82
ClassAttribute cssClasses()

Returns the class attribute object

Return Value

ClassAttribute

the class attribute object

in AbstractTag at line 87
Component css(array|string|null $styles = null)

Sets the inline styles

Parameters

array|string|null $styles

the inline style(s) to set

Return Value

Component

for a fluent interface

Exceptions

InvalidArgumentException
ImmutableAttributeException

in AbstractTag at line 93
StyleAttribute style()

Returns the attribute object containing inline styles

Return Value

StyleAttribute

the attribute object containing inline styles

in AbstractTag at line 98
Component setAttribute(string $name, mixed $value = true)

Sets an attribute name value pair

IMPORTANT!: Does not alter locked attribute values:

  1. For 'class' attribute: if a CSS class name is locked the method does nothing
  2. For any other locked attribute the method throws a UnmodifiableAttributeException

$value parameter:

  1. the type of the value should always convert to string
  2. null or an empty string: an empty attribute is set
  3. boolean true: an empty attribute is set
  4. boolean false: attribute is removed
  5. otherwise the attribute value is the string conversion value

Parameters

string $name

the name of the attribute

mixed $value

the value of the attribute

Return Value

Component

for a fluent interface

Exceptions

InvalidArgumentException
ImmutableAttributeException

in AbstractTag at line 104
Component removeAttribute(string $name)

Removes given attribute if it is not locked

Parameters

string $name

Return Value

Component

for a fluent interface

Exceptions

ImmutableAttributeException

in AbstractTag at line 110
mixed getAttribute(string $name)

Returns the value of a given attribute name or an empty string if attribute is not set

Parameters

string $name

Return Value

mixed

the value of the attribute

in AbstractTag at line 115
bool attributeExists(string $name)

Checks if an attribute exists

Parameters

string $name

Return Value

bool

(attribute exists)

in AbstractTag at line 120
CssClassifiableContent addCssClass(string ...$cssClasses)

Adds the specified CSS class names

Important: a single $cssClasses argument can contain multiple comma separated CSS class names.

Parameters

string ...$cssClasses

CSS class names to add

Return Value

CssClassifiableContent

for a fluent interface

in AbstractTag at line 126
CssClassifiableContent removeCssClass(string ...$cssClasses)

Removes given CSS class names

Important: a single $cssClasses argument can contain multiple comma separated CSS class names.

Parameters

string ...$cssClasses

CSS class names to remove

Return Value

CssClassifiableContent

for a fluent interface

in AbstractTag at line 132
bool hasCssClass(string ...$cssClasses)

Determines whether the given CSS class names are stored into the manager

Important: a single $cssClasses argument can contain multiple comma separated CSS class names.

Parameters

string ...$cssClasses

CSS class names to search for

Return Value

bool

true if he given CSS class names are stored, false otherwise

in AbstractComponent at line 29
string getOpeningTag()

Returns opening tag with its attributes

Return Value

string

opening tag with attributes

at line 58
string contentToString()

Returns the content of the component as a string

Return Value

string

content as a string

Exceptions

HtmlException

in AbstractComponent at line 51
string getClosingTag()

Returns closing tag

Return Value

string

closing tag

in AbstractComponent at line 56
string __toString()

Gets a string representation of the object

Return Value

string

Returns the ```string``` representation of the object.

at line 47
InlineScript appendJavaScript(string $code)

No description

Parameters

string $code

Return Value

InlineScript

at line 53
string getHash()

Returns the hash value

Return Value

string