public function __construct(\Closure $closure, MicroDateTime $startedOn, MicroDateTime $endsOn, $results = null) { if (empty($results)) { $results = null; } if (!$startedOn->isBefore($endsOn)) { throw new MicroDateTimeClosureException('The startedOn MicroDateTime must be before the endsOn MicroDateTime.'); } $this->closure = $closure; $this->startedOn = $startedOn; $this->endsOn = $endsOn; $this->results = $results; }
public function isBefore(MicroDateTime $microDateTime) { $fromTimestamp = $this->dateTime->getTimestamp(); $toTimestamp = $microDateTime->getDateTime()->getTimestamp(); if ($fromTimestamp < $toTimestamp) { return true; } $fromMicroSeconds = $this->microSeconds; $toMicroSeconds = $microDateTime->getMicroSeconds(); if ($fromMicroSeconds < $toMicroSeconds) { return true; } return false; }