class ScriptSrc extends AbstractScriptTag

Implements an HTML script tag having script code as its content

IMPORTANT:

This component points to an external script file through the src attribute.

Methods

string
__toString()

Returns the component as HTML markup string

$this
printHtml()

Prints the component as HTML markup string

__construct(string $src = null)

Constructor

__destruct()

Destructor

__clone()

Clones the object

string
getTagName()

Returns the tag name of the component

attributes()

Returns the attribute manager attached to the component

string
identify(int $length = 16)

Identifies the element with an unique id attribute

cssClasses()

Returns the class attribute object

inlineStyles()

Returns the attribute object containing inline styles

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

Sets an attribute name value pair

$this
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

string
attributesToString()

No description

$this
addCssClass(string|string[],... ...$cssClasses)

Adds the specified CSS class names

$this
removeCssClass(string|string[],... ...$cssClasses)

Removes given CSS class names

bool
hasCssClass(string|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
getHtml()

Returns the component as HTML markup string

$this
setType(string $type = null)

Specifies the MIME type of the script

$this
setAsync(bool $async = true)

Sets whether the script is executed asynchronously

bool
isAsync()

Checks whether the script is executed asynchronously

$this
setDefer(bool $defer = true)

Sets whether the script will not run until after the page has loaded

bool
isDefered()

Checks whether the script will not run until after the page has loaded

$this
setIntegrity(string $hash = null, string $crossorigin = null)

Sets subresource integrity

$this
setSrc(string $src = null)

Sets the URL of the script file

string|null
getSrc()

Returns the URL of the script file

Details

in AbstractContent at line 27
string __toString()

Returns the component as HTML markup string

Return Value

string HTML markup of the object

in AbstractContent at line 36
$this printHtml()

Prints the component as HTML markup string

Return Value

$this for a fluent interface

at line 41
__construct(string $src = null)

Constructor

IMPORTANT:

This component points to an external script file through the src attribute.

Parameters

string $src the URL of the script file

in AbstractTag at line 69
__destruct()

Destructor

in AbstractTag at line 80
__clone()

Clones the object

Note: Method cannot be called directly!

in AbstractTag at line 86
string getTagName()

Returns the tag name of the component

Return Value

string the tag name of the component

in AbstractTag at line 90
HtmlAttributeManager attributes()

Returns the attribute manager attached to the component

Return Value

HtmlAttributeManager the attribute manager

in AbstractTag at line 97
string identify(int $length = 16)

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

int $length the length of the identity value

Return Value

string the identifier

in AbstractTag at line 101
ClassAttribute cssClasses()

Returns the class attribute object

Return Value

ClassAttribute the class attribute object

in AbstractTag at line 105
PropertyCollectionAttribute inlineStyles()

Returns the attribute object containing inline styles

Return Value

PropertyCollectionAttribute the attribute object containing inline styles

in AbstractTag at line 109
$this 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 {@link 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

$this for a fluent interface

Exceptions

InvalidArgumentException if the attribute name or value is invalid
ImmutableAttributeException if the attribute value is unmodifiable

in AbstractTag at line 114
$this removeAttribute(string $name)

Removes given attribute if it is not locked

Parameters

string $name

Return Value

$this for a fluent interface

Exceptions

ImmutableAttributeException if the attribute value is unmodifiable

in AbstractTag at line 119
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 123
bool attributeExists(string $name)

Checks if an attribute exists

Parameters

string $name

Return Value

bool (attribute exists)

in AbstractTag at line 127
protected string attributesToString()

Return Value

string

in AbstractTag at line 135
$this addCssClass(string|string[],... ...$cssClasses)

Adds the specified CSS class names

Important: Parameter $cssClasses restrictions and rules

  1. A string parameter can contain multiple space separated CSS class names
  2. An array parameter can contain only one CSS class name per value
  3. Duplicate CSS class names are not stored

Parameters

string|string[],... ...$cssClasses CSS class names to add

Return Value

$this for a fluent interface

in AbstractTag at line 140
$this removeCssClass(string|string[],... ...$cssClasses)

Removes given CSS class names

Important: Parameter $cssClasses restrictions and rules

  1. A string parameter can contain multiple comma separated CSS class names
  2. An array parameter can contain only one CSS class name per value

Parameters

string|string[],... ...$cssClasses CSS class names to remove

Return Value

$this for a fluent interface

in AbstractTag at line 145
bool hasCssClass(string|string[],... ...$cssClasses)

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

Important: Parameter $cssClasses restrictions and rules

  1. A string parameter can contain multiple comma separated CSS class names
  2. An array parameter can contain only one CSS class name per value

Parameters

string|string[],... ...$cssClasses CSS class names to search for

Return Value

bool for a fluent interface

in AbstractComponent at line 30
string getOpeningTag()

Returns opening tag with its attributes

Return Value

string opening tag with attributes

at line 88
string contentToString()

Returns the content of the component as a string

Return Value

string content as a string

Exceptions

RuntimeException if content parsing fails

in AbstractComponent at line 47
string getClosingTag()

Returns closing tag

Return Value

string closing tag

in AbstractComponent at line 51
string getHtml()

Returns the component as HTML markup string

Return Value

string HTML markup of the component

Exceptions

SphpExceptionInterface if HTML parsing fails

in AbstractScriptTag at line 49
$this setType(string $type = null)

Specifies the MIME type of the script

Parameters

string $type the value of the type attribute (mime-type)

Return Value

$this for a fluent interface

in AbstractScriptTag at line 54
$this setAsync(bool $async = true)

Sets whether the script is executed asynchronously

Asynchronous script will be executed as soon as it is available.

Parameters

bool $async true for asynchronous execution, false otherwise

Return Value

$this for a fluent interface

in AbstractScriptTag at line 61
bool isAsync()

Checks whether the script is executed asynchronously

Asynchronous script will be executed as soon as it is available.

Return Value

bool true for asynchronous execution, false otherwise

in AbstractScriptTag at line 65
$this setDefer(bool $defer = true)

Sets whether the script will not run until after the page has loaded

Parameters

bool $defer true for deferred execution, false otherwise

Return Value

$this for a fluent interface

in AbstractScriptTag at line 72
bool isDefered()

Checks whether the script will not run until after the page has loaded

Return Value

bool true for deferred execution, false otherwise

at line 55
$this setIntegrity(string $hash = null, string $crossorigin = null)

Sets subresource integrity

Parameters

string $hash a base64-encoded cryptographic hash of a resource (file)
string $crossorigin CORS access to content Request

Return Value

$this for a fluent interface

at line 73
$this setSrc(string $src = null)

Sets the URL of the script file

Parameters

string $src the URL of the script file

Return Value

$this for a fluent interface

at line 84
string|null getSrc()

Returns the URL of the script file

Return Value

string|null the URL of the script file