UnitPriceSpecificationTrait
Helpers to inspect a collection of {@see \org\schema\UnitPriceSpecification} objects.
Tags
Table of Contents
Methods
- getLastUnitPriceSpecification() : UnitPriceSpecification|null
- Retrieves the latest UnitPriceSpecification based on the given property name.
Methods
getLastUnitPriceSpecification()
Retrieves the latest UnitPriceSpecification based on the given property name.
public
getLastUnitPriceSpecification(array<string|int, UnitPriceSpecification>|null $specifications[, string $propertyName = Schema::VALID_FROM ][, string $format = Iso8601Format::DATE ]) : UnitPriceSpecification|null
Iterates through the provided specifications to identify the UnitPriceSpecification with the most recent date based on the specified property. If no valid date is found in the specifications, or if the input array is null, the method returns null.
Parameters
- $specifications : array<string|int, UnitPriceSpecification>|null
-
Array of specifications to be evaluated.
- $propertyName : string = Schema::VALID_FROM
-
The property used to extract the date for comparison. Defaults to Schema::VALID_FROM.
- $format : string = Iso8601Format::DATE
-
The date format the compared values are expected in. Defaults to Iso8601Format::DATE (
'Y-m-d').
Return values
UnitPriceSpecification|null —The latest UnitPriceSpecification or null if not found.