AttributeHolder
AttributeHolder provides a base class for managing attributes with namespaces.
It contains all the functionality ParameterHolder provides.
Synopsis
Section titled “Synopsis”abstract class AttributeHolder extends ParameterHolder
| Extends | ParameterHolder |
| Since | 1.0.0 |
| Source | Util/AttributeHolder.php |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
$attributes | mixed | protected. |
$defaultNamespace | mixed | protected. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
| [`appendAttribute(int | string $name, mixed $value, string $ns = null): void`](#appendattribute) |
| [`appendAttributeByRef(int | string $name, mixed &$value, string $ns = null): void`](#appendattributebyref) |
clearAttributes(): void | Clear all attributes. |
| [`getAttribute(int | string $name, string $ns = null, mixed $default = null): mixed`](#getattribute) |
| [`getAttributeNames(string $ns = null): ?array<int, int | string>`](#getattributenames) |
| [`getAttributeNamespace(string $ns = null): array<int | string, mixed> |
getAttributeNamespaces(): array<int, string> | Retrieve an array of attribute namespaces. |
| [`getAttributes(string $ns = null): array<int | string, mixed>`](#getattributes) |
getDefaultNamespace(): string | Get the default namespace name |
getFlatAttributeNames(string $ns = null): ?array<int, string> | Retrieve an array of flattened attribute names. |
| [`hasAttribute(int | string $name, string $ns = null): bool`](#hasattribute) |
hasAttributeNamespace(string $ns): bool | Indicates whether or not an attribute namespace exists. |
| [`removeAttribute(int | string $name, string $ns = null): mixed`](#removeattribute) |
removeAttributeNamespace(string $ns): mixed | Remove an attribute namespace and all of its associated attributes. |
| [`setAttribute(int | string $name, mixed $value, string $ns = null): void`](#setattribute) |
| [`setAttributeByRef(int | string $name, mixed &$value, string $ns = null): void`](#setattributebyref) |
| [`setAttributes(array<int | string, mixed> $attributes, string $ns = null): void`](#setattributes) |
| [`setAttributesByRef(array<int | string, mixed> &$attributes, string $ns = null): void`](#setattributesbyref) |
appendAttribute()
Section titled “appendAttribute()”public function appendAttribute(int|string $name, mixed $value, string $ns = null): void
Append an attribute.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$name | `int“ | “string` |
$value | mixed | An attribute value. |
$ns | string | An attribute namespace. |
appendAttributeByRef()
Section titled “appendAttributeByRef()”public function appendAttributeByRef(int|string $name, mixed &$value, string $ns = null): void
Append an attribute by reference.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$name | `int“ | “string` |
$value | mixed | A reference to an attribute value. |
$ns | string | An attribute namespace. |
clearAttributes()
Section titled “clearAttributes()”public function clearAttributes(): void
Clear all attributes.
getAttribute()
Section titled “getAttribute()”public function getAttribute(int|string $name, string $ns = null, mixed $default = null): mixed
Retrieve an attribute.
A default attribute value.
| Parameter | Type | Description |
|---|---|---|
$name | `int“ | “string` |
$ns | string | An attribute namespace. |
$default | mixed | A default attribute value. |
Returns mixed — An attribute value, if the attribute exists, otherwise null.
getAttributeNames()
Section titled “getAttributeNames()”public function getAttributeNames(string $ns = null): ?array<int, int|string>
Retrieve an array of attribute names.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$ns | string | An attribute namespace. |
Returns ?``array``<``int``, ``int``|``string``> — An indexed array of attribute names, if the namespace exists, otherwise null.
getAttributeNamespace()
Section titled “getAttributeNamespace()”public function getAttributeNamespace(string $ns = null): array<int|string, mixed>|null
Retrieve all attributes within a namespace.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$ns | string | An attribute namespace. |
Returns array``<``int``|``string``, ``mixed``>``|``null — An associative array of attributes if the namespace exists, otherwise null.
getAttributeNamespaces()
Section titled “getAttributeNamespaces()”public function getAttributeNamespaces(): array<int, string>
Retrieve an array of attribute namespaces.
Returns array``<``int``, ``string``> — An indexed array of attribute namespaces.
getAttributes()
Section titled “getAttributes()”public function getAttributes(string $ns = null): array<int|string, mixed>
Retrieve all attributes within a namespace.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$ns | string | An attribute namespace. |
Returns array``<``int``|``string``, ``mixed``> — An associative array of attributes.
getDefaultNamespace()
Section titled “getDefaultNamespace()”public function getDefaultNamespace(): string
Get the default namespace name
Returns string — The default namespace name
getFlatAttributeNames()
Section titled “getFlatAttributeNames()”public function getFlatAttributeNames(string $ns = null): ?array<int, string>
Retrieve an array of flattened attribute names.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$ns | string | An attribute namespace. |
Returns ?``array``<``int``, ``string``> — An indexed array of attribute names, if the namespace exists, otherwise null.
hasAttribute()
Section titled “hasAttribute()”public function hasAttribute(int|string $name, string $ns = null): bool
Indicates whether or not an attribute exists.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$name | `int“ | “string` |
$ns | string | An attribute namespace. |
Returns bool — true, if the attribute exists, otherwise false.
hasAttributeNamespace()
Section titled “hasAttributeNamespace()”public function hasAttributeNamespace(string $ns): bool
Indicates whether or not an attribute namespace exists.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$ns | string | An attribute namespace. |
Returns bool — true, if the namespace exists, otherwise false.
removeAttribute()
Section titled “removeAttribute()”public function removeAttribute(int|string $name, string $ns = null): mixed
Remove an attribute.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$name | `int“ | “string` |
$ns | string | An attribute namespace. |
Returns mixed — An attribute value, if the attribute was removed, otherwise null.
removeAttributeNamespace()
Section titled “removeAttributeNamespace()”public function removeAttributeNamespace(string $ns): mixed
Remove an attribute namespace and all of its associated attributes.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$ns | string | An attribute namespace. |
Returns mixed — An array with all namespace attributes, if the namespace was removed, or null otherwise.
setAttribute()
Section titled “setAttribute()”public function setAttribute(int|string $name, mixed $value, string $ns = null): void
Set an attribute.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$name | `int“ | “string` |
$value | mixed | An attribute value. |
$ns | string | An attribute namespace. |
setAttributeByRef()
Section titled “setAttributeByRef()”public function setAttributeByRef(int|string $name, mixed &$value, string $ns = null): void
Set an attribute by reference.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$name | `int“ | “string` |
$value | mixed | A reference to an attribute value. |
$ns | string | An attribute namespace. |
setAttributes()
Section titled “setAttributes()”public function setAttributes(array<int|string, mixed> $attributes, string $ns = null): void
Set an array of attributes.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$attributes | `array<int“ | string, mixed>` |
$ns | string | An attribute namespace. |
setAttributesByRef()
Section titled “setAttributesByRef()”public function setAttributesByRef(array<int|string, mixed> &$attributes, string $ns = null): void
Set an array of attributes by reference.
An attribute namespace.
| Parameter | Type | Description |
|---|---|---|
$attributes | `array<int“ | string, mixed>` |
$ns | string | An attribute namespace. |
Inherited methods
Section titled “Inherited methods”These come from an ancestor and are documented where they are declared.
| Method | Declared in | Description |
|---|---|---|
appendParameter() | ParameterHolder | Append a parameter. |
appendParameterByRef() | ParameterHolder | Append a parameter by reference. |
clearParameters() | ParameterHolder | Clear all parameters associated with this request. |
getFlatParameterNames() | ParameterHolder | Retrieve an array of flattened parameter names. |
getParameter() | ParameterHolder | Retrieve a parameter. |
getParameterNames() | ParameterHolder | Retrieve an array of parameter names. |
getParameters() | ParameterHolder | Retrieve an array of parameters. |
hasParameter() | ParameterHolder | Indicates whether or not a parameter exists. |
removeParameter() | ParameterHolder | Remove a parameter. |
reset() | ParameterHolder | Removes every parameter held, leaving the holder empty for reuse. |
setParameter() | ParameterHolder | Set a parameter. |
setParameterByRef() | ParameterHolder | Set a parameter by reference. |
setParameters() | ParameterHolder | Set an array of parameters. |
setParametersByRef() | ParameterHolder | Set an array of parameters by reference. |