Calculator
in package
implements
CalculatorInterface
FinalYes
Order fulfillment deadline calculator interface.
Tags
Table of Contents
Interfaces
- CalculatorInterface
- Order fulfillment deadline calculator interface.
Properties
- $serviceHoursProvider : ProviderInterface
- Order processing hours provider.
Methods
- __construct() : mixed
- Calculator constructor.
- calculate() : DateTimeInterface|null
- Calculates order fulfillment deadline.
- compareTime() : int
- Compares given timestamps.
- duplicateDateTime() : DateTime
- Returns a mutable copy of the given timestamp.
- secondsToTime() : array<string|int, int>
- Converts seconds to hours, minutes and seconds.
Properties
$serviceHoursProvider
Order processing hours provider.
private
ProviderInterface
$serviceHoursProvider
Methods
__construct()
Calculator constructor.
public
__construct(ProviderInterface $serviceHoursProvider) : mixed
Parameters
- $serviceHoursProvider : ProviderInterface
-
order processing hours provider
calculate()
Calculates order fulfillment deadline.
public
calculate(Input $input) : DateTimeInterface|null
Parameters
- $input : Input
-
calculation input data
Tags
Return values
DateTimeInterface|null —fulfillment deadline or null
if N/A or unknown
compareTime()
Compares given timestamps.
private
static compareTime(DateTimeInterface $a, int $b) : int
Parameters
- $a : DateTimeInterface
-
timestamp
- $b : int
-
seconds since midnight
Return values
int —zero if times are equal, negative if $a
is lesser, positive if $b
is lesser
duplicateDateTime()
Returns a mutable copy of the given timestamp.
private
duplicateDateTime(DateTimeInterface $dateTime) : DateTime
Parameters
- $dateTime : DateTimeInterface
-
timestamp to copy
Return values
DateTime —copy
secondsToTime()
Converts seconds to hours, minutes and seconds.
private
static secondsToTime(int $timestamp) : array<string|int, int>
Parameters
- $timestamp : int
-
seconds
Tags
Return values
array<string|int, int> —array with keys hours
, minutes
and seconds