\OntologyWrapper\traitsAccessorOffset

Offset accessor trait

The main purpose of this trait is to provide a series of templates for managing object offsets and structure components. The idea is to provide a common framework to member accessor methods by sharing standards.

This trait implements the following protected methods:

  • {@link manageOffset()}: This method provides a standard interface to set, retrieve and delete offset values.
  • {@link manageSetOffset()}: This method provides a standard interface to set, retrieve and delete elements of an array set, this method provides access to elements of the offset, rather than to the offset, which must be an array or {@link ArrayObject}.
  • {@link manageArrayOffset()}: This method provides a standard interface to set, retrieve and delete key/value pair elements based on their key.
  • {@link manageElementMatchOffset()}: This method provides a standard interface to set, retrieve and delete elements of an array or {@link ArrayObject}, these elements are an array of two items in which the first one is the discriminator and the second is the value.

Summary

Methods
Properties
Constants
No public methods found
No public properties found
No constants found
manageOffset()
manageSetOffset()
manageArrayOffset()
manageElementMatchOffset()
manageElementListOffset()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

manageOffset()

manageOffset(string $theOffset, mixed $theValue, boolean $getOld) : mixed

<h4>Manage a scalar offset</h4>

This class provides a protected interface for member accessor methods, both for properties and offsets, this method can be used to manage a scalar offset, its options involve setting, retrieving and deleting an offset of the provided array or ArrayObject.

The method accepts the following parameters:

  • $theOffset: The offset to the attribute contained in the previous parameter that is to be managed.
  • $theValue: The value or operation:
    • NULL: Return the offset's current value.
    • FALSE: Delete the offset.
    • other: Any other type represents the offset's new value.
  • $getOld: Determines what the method will return:
    • TRUE: Return the value of the offset before it was eventually modified.
    • FALSE: Return the value of the offset after it was eventually modified.

Parameters

string $theOffset

Offset to be managed.

mixed $theValue

New value or operation.

boolean $getOld

TRUE get old value.

Returns

mixed —

Old or new value.

manageSetOffset()

manageSetOffset(string $theOffset, mixed $theValue, mixed $theOperation, boolean $getOld) : mixed

<h4>Manage value set offset</h4>

This class provides a protected interface for member accessor methods, both for properties and offsets, this method can be used to manage the elements of a set of non repeting values, its options involve setting, retrieving and deleting elements of the set. This method generally applies to data of the {@link kTYPE_SET} data type.

It is assumed that the value at the provided offset is either an array or an {@link ArrayObject}, if this is not the case, the method will raise an exception.

If you want to manage the set itself, you have to use the offset management methods.

The method accepts the following parameters:

  • $theOffset: The offset to the array attribute that is to be managed.
  • $theValue: The value of the array element.
  • $theOperation: The operation:
    • NULL: Return the value if it exists or NULL.
    • FALSE: Delete the value if it exists.
    • other: Any other type represents a new value.
  • $getOld: Determines what the method will return:
    • TRUE: Return the value before it was eventually modified.
    • FALSE: Return the value after it was eventually modified.

When setting new values, if the current offset is empty, the method will set the new value in an aray; when deleting values, if the existing value is the last one, the method will delete the offset itself.

Parameters

string $theOffset

Offset to be managed.

mixed $theValue

Array value.

mixed $theOperation

Operation.

boolean $getOld

TRUE get old value.

Throws

\OntologyWrapper\traits\Exception

Returns

mixed —

Old or new value.

manageArrayOffset()

manageArrayOffset(string $theOffset, mixed $theKey, mixed $theValue, boolean $getOld) : mixed

<h4>Manage value set offset</h4>

This class provides a protected interface for member accessor methods, both for properties and offsets, this method can be used to manage the elements of a key/value array, its options involve setting, retrieving and deleting elements of the list by key. This method generally applies to data of the {@link kTYPE_ARRAY} data type.

It is assumed that the value at the provided offset is either an array or an {@link ArrayObject}, if this is not the case, the method will raise an exception.

If you want to manage the array itself, you have to use the offset management

  • methods.

The method accepts the following parameters:

  • $theOffset: The offset to the array attribute that is to be managed.
  • $theKey: The element key.
  • $theValue: The element value or operation:
    • NULL: Return the value at the provided key, or NULL.
    • FALSE: Delete the value at the provided key.
    • other: Any other type represents a new or a replacement value.
  • $getOld: Determines what the method will return:
    • TRUE: Return the value before it was eventually modified.
    • FALSE: Return the value after it was eventually modified.

When setting new values, if the current offset is empty, the method will set the new value in an aray; when deleting values, if the existing value is the last one, the method will delete the offset itself.

Parameters

string $theOffset

Offset to be managed.

mixed $theKey

Element key.

mixed $theValue

Element value or operation.

boolean $getOld

TRUE get old value.

Throws

\OntologyWrapper\traits\Exception

Returns

mixed —

Old or new value.

manageElementMatchOffset()

manageElementMatchOffset(string $theOffset, string $theTypeOffset, string $theDataOffset, string $theTypeValue, mixed $theDataValue, boolean $getOld) : mixed

<h4>Manage element match offset</h4>

This class provides a protected interface for member accessor methods, both for properties and offsets, this method can be used to manage the elements of an array of array elements in which one item's value represents the discriminant.

Offsets of this kind are arrays that represent a list of elements, each of which is constituted by an array of two items, where the value matching the $theTypeOffset key represents the element key and the value matching the $theDataOffset key represents the element's value.

This method allows retrieving the element value and deleting or setting an element.

It is assumed that the value at the provided offset is an array, if this is not the case, the method will raise an exception.

If you want to manage the set itself, you have to use the offset management methods.

The method accepts the following parameters:

  • $theOffset: The offset to the attribute containing the match list.
  • $theTypeOffset: The offset to the type within the element.
  • $theDataOffset: The offset to the data within the element.
  • $theTypeValue: The value of the element's type to match, it represents the key to the element; we assume the value to be a string. A NULL value is used to select the element missing the $theTypeOffset offset.
  • $theDataValue: The value or operation:
    • NULL: Return the offset's $theDataOffset value.
    • FALSE: Delete the element matchhing the $theTypeOffset.
    • other: Any other type represents the element's new value.
  • $getOld: Determines what the method will return:
    • TRUE: Return the value of the offset before it was eventually modified.
    • FALSE: Return the value of the offset after it was eventually modified.

The method expects each element to be a structure containing at least an element indexed by the $theDataOffset offset, if that is not the case, the method will raise an exception. All elements are supposed to be arrays.

Parameters

string $theOffset

Offset to be managed.

string $theTypeOffset

Offset of type item.

string $theDataOffset

Offset of data item.

string $theTypeValue

Type value.

mixed $theDataValue

New value or operation.

boolean $getOld

TRUE get old value.

Throws

\OntologyWrapper\traits\Exception

Returns

mixed —

Old or new value.

manageElementListOffset()

manageElementListOffset(string $theOffset, string $theTypeOffset, string $theDataOffset, string $theTypeValue, mixed $theDataValue, mixed $theOperation, boolean $getOld) : mixed

<h4>Manage element list offset</h4>

This class provides a protected interface for member accessor methods, both for properties and offsets, this method can be used to manage the elements of an array of array elements in which one item's value represents the discriminant and the other item is a list of values.

Offsets of this kind are arrays that represent a list of elements, each of which is constituted by an array of two items, where the value matching the $theTypeOffset key represents the element key and the value matching the $theDataOffset key represents the element's value. The element's value, in this case, is a list of values: this method allows managing the individual elements of this list.

It is assumed that the value at the provided offset is an array, if this is not the case, the method will raise an exception.

If you want to manage the set itself, you have to use the offset management methods.

The method accepts the following parameters:

  • $theOffset: The offset to the attribute containing the match list.
  • $theTypeOffset: The offset to the element item representing the discriminator.
  • $theDataOffset: The offset to the element holding the list of values related to the discriminator.
  • $theTypeValue: The value of the discriminator element to match.
  • $theDataValue: The value of the list element related to the discriminator, or the list operation:
    • NULL: Select all the elements of the list related to the provided discriminator.
    • other: Any other type will be cast to a string and will represent the list value to be matched.
  • $theOperation: The operation to be performed:
    • NULL: Return the list value matched by the $theDataValue parameter.
    • FALSE: Delete the list value matched by the $theDataValue parameter.
    • TRUE: Add the list value provided in the $theDataValue parameter to the list.
  • $getOld: Determines what the method will return:
    • TRUE: Return the value before it was eventually modified.
    • FALSE: Return the value after it was eventually modified.

The method expects each element to be a structure containing containing both the $theTypeOffset and $theDataOffset items, if that is not the case, the method will raise an exception. All elements are supposed to be arrays.

Parameters

string $theOffset

Offset to be managed.

string $theTypeOffset

Offset of type item.

string $theDataOffset

Offset of data item.

string $theTypeValue

Discriminator value.

mixed $theDataValue

Lis value selector.

mixed $theOperation

Operation.

boolean $getOld

TRUE get old value.

Throws

\OntologyWrapper\traits\Exception

Returns

mixed —

Old or new value.