Skip to content

AttributeHolder

AttributeHolder provides a base class for managing attributes with namespaces.

It contains all the functionality ParameterHolder provides.

abstract class AttributeHolder extends ParameterHolder

ExtendsParameterHolder
Since1.0.0
SourceUtil/AttributeHolder.php
PropertyTypeDescription
$attributesmixedprotected.
$defaultNamespacemixedprotected.
MethodDescription
[`appendAttribute(intstring $name, mixed $value, string $ns = null): void`](#appendattribute)
[`appendAttributeByRef(intstring $name, mixed &$value, string $ns = null): void`](#appendattributebyref)
clearAttributes(): voidClear all attributes.
[`getAttribute(intstring $name, string $ns = null, mixed $default = null): mixed`](#getattribute)
[`getAttributeNames(string $ns = null): ?array<int, intstring>`](#getattributenames)
[`getAttributeNamespace(string $ns = null): array<intstring, mixed>
getAttributeNamespaces(): array<int, string>Retrieve an array of attribute namespaces.
[`getAttributes(string $ns = null): array<intstring, mixed>`](#getattributes)
getDefaultNamespace(): stringGet the default namespace name
getFlatAttributeNames(string $ns = null): ?array<int, string>Retrieve an array of flattened attribute names.
[`hasAttribute(intstring $name, string $ns = null): bool`](#hasattribute)
hasAttributeNamespace(string $ns): boolIndicates whether or not an attribute namespace exists.
[`removeAttribute(intstring $name, string $ns = null): mixed`](#removeattribute)
removeAttributeNamespace(string $ns): mixedRemove an attribute namespace and all of its associated attributes.
[`setAttribute(intstring $name, mixed $value, string $ns = null): void`](#setattribute)
[`setAttributeByRef(intstring $name, mixed &$value, string $ns = null): void`](#setattributebyref)
[`setAttributes(array<intstring, mixed> $attributes, string $ns = null): void`](#setattributes)
[`setAttributesByRef(array<intstring, mixed> &$attributes, string $ns = null): void`](#setattributesbyref)

public function appendAttribute(int|string $name, mixed $value, string $ns = null): void

Append an attribute.

An attribute namespace.

ParameterTypeDescription
$name`int““string`
$valuemixedAn attribute value.
$nsstringAn attribute namespace.

public function appendAttributeByRef(int|string $name, mixed &$value, string $ns = null): void

Append an attribute by reference.

An attribute namespace.

ParameterTypeDescription
$name`int““string`
$valuemixedA reference to an attribute value.
$nsstringAn attribute namespace.

public function clearAttributes(): void

Clear all attributes.

public function getAttribute(int|string $name, string $ns = null, mixed $default = null): mixed

Retrieve an attribute.

A default attribute value.

ParameterTypeDescription
$name`int““string`
$nsstringAn attribute namespace.
$defaultmixedA default attribute value.

Returns mixed — An attribute value, if the attribute exists, otherwise null.

public function getAttributeNames(string $ns = null): ?array<int, int|string>

Retrieve an array of attribute names.

An attribute namespace.

ParameterTypeDescription
$nsstringAn attribute namespace.

Returns ?``array``<``int``, ``int``|``string``> — An indexed array of attribute names, if the namespace exists, otherwise null.

public function getAttributeNamespace(string $ns = null): array<int|string, mixed>|null

Retrieve all attributes within a namespace.

An attribute namespace.

ParameterTypeDescription
$nsstringAn attribute namespace.

Returns array``<``int``|``string``, ``mixed``>``|``null — An associative array of attributes if the namespace exists, otherwise null.

public function getAttributeNamespaces(): array<int, string>

Retrieve an array of attribute namespaces.

Returns array``<``int``, ``string``> — An indexed array of attribute namespaces.

public function getAttributes(string $ns = null): array<int|string, mixed>

Retrieve all attributes within a namespace.

An attribute namespace.

ParameterTypeDescription
$nsstringAn attribute namespace.

Returns array``<``int``|``string``, ``mixed``> — An associative array of attributes.

public function getDefaultNamespace(): string

Get the default namespace name

Returns string — The default namespace name

public function getFlatAttributeNames(string $ns = null): ?array<int, string>

Retrieve an array of flattened attribute names.

An attribute namespace.

ParameterTypeDescription
$nsstringAn attribute namespace.

Returns ?``array``<``int``, ``string``> — An indexed array of attribute names, if the namespace exists, otherwise null.

public function hasAttribute(int|string $name, string $ns = null): bool

Indicates whether or not an attribute exists.

An attribute namespace.

ParameterTypeDescription
$name`int““string`
$nsstringAn attribute namespace.

Returns bool — true, if the attribute exists, otherwise false.

public function hasAttributeNamespace(string $ns): bool

Indicates whether or not an attribute namespace exists.

An attribute namespace.

ParameterTypeDescription
$nsstringAn attribute namespace.

Returns bool — true, if the namespace exists, otherwise false.

public function removeAttribute(int|string $name, string $ns = null): mixed

Remove an attribute.

An attribute namespace.

ParameterTypeDescription
$name`int““string`
$nsstringAn attribute namespace.

Returns mixed — An attribute value, if the attribute was removed, otherwise null.

public function removeAttributeNamespace(string $ns): mixed

Remove an attribute namespace and all of its associated attributes.

An attribute namespace.

ParameterTypeDescription
$nsstringAn attribute namespace.

Returns mixed — An array with all namespace attributes, if the namespace was removed, or null otherwise.

public function setAttribute(int|string $name, mixed $value, string $ns = null): void

Set an attribute.

An attribute namespace.

ParameterTypeDescription
$name`int““string`
$valuemixedAn attribute value.
$nsstringAn attribute namespace.

public function setAttributeByRef(int|string $name, mixed &$value, string $ns = null): void

Set an attribute by reference.

An attribute namespace.

ParameterTypeDescription
$name`int““string`
$valuemixedA reference to an attribute value.
$nsstringAn attribute namespace.

public function setAttributes(array<int|string, mixed> $attributes, string $ns = null): void

Set an array of attributes.

An attribute namespace.

ParameterTypeDescription
$attributes`array<int“string, mixed>`
$nsstringAn attribute namespace.

public function setAttributesByRef(array<int|string, mixed> &$attributes, string $ns = null): void

Set an array of attributes by reference.

An attribute namespace.

ParameterTypeDescription
$attributes`array<int“string, mixed>`
$nsstringAn attribute namespace.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearParameters()ParameterHolderClear all parameters associated with this request.
getFlatParameterNames()ParameterHolderRetrieve an array of flattened parameter names.
getParameter()ParameterHolderRetrieve a parameter.
getParameterNames()ParameterHolderRetrieve an array of parameter names.
getParameters()ParameterHolderRetrieve an array of parameters.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
removeParameter()ParameterHolderRemove a parameter.
reset()ParameterHolderRemoves every parameter held, leaving the holder empty for reuse.
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.