class AttributeHelper (View source)

Helper class to deal with mixed array and Attribute operations.

This class contains static methods only and is not meant to be instantiated.

Methods

static bool
attributeExists(string $name, Attribute|array $collection)

Checks if the given attribute collection has an attribute.

static Attribute|array
mergeCollections(Attribute|array $a, Attribute|array $b)

Merges two attribute collections.

Details

static bool attributeExists(string $name, Attribute|array $collection)

Checks if the given attribute collection has an attribute.

Parameters

string $name

The name of the attribute to check for.

Attribute|array $collection

An Attribute object or an array of attributes.

Return Value

bool

TRUE if the attribute exists, FALSE otherwise.

Exceptions

InvalidArgumentException

static Attribute|array mergeCollections(Attribute|array $a, Attribute|array $b)

Merges two attribute collections.

Parameters

Attribute|array $a

First Attribute object or array to merge. The returned value type will be the same as the type of this argument.

Attribute|array $b

Second Attribute object or array to merge.

Return Value

Attribute|array

The merged attributes, as an Attribute object or an array.

Exceptions

InvalidArgumentException