rescan; } /** * Set whether this job should do only a rescan or full scan * * @param bool $rescan * * @return $this */ public function setRescan(bool $rescan): self { $this->rescan = $rescan; return $this; } public function getParallel(): int { return $this->parallel; } public function setParallel(int $parallel): self { $this->parallel = $parallel; return $this; } /** * Set whether this job should scan all known and unknown targets * * @param bool $fullScan * * @return $this */ public function setFullScan(bool $fullScan): self { $this->fullScan = $fullScan; return $this; } /** * Set since last scan threshold for the targets to rescan * * @param ?string $time * * @return $this */ public function setLastScan(?string $time): self { if ($time && $time !== 'null') { $sinceLastScan = $time; if ($sinceLastScan[0] !== '-') { // When the user specified "2 days" as a threshold strtotime() will compute the // timestamp NOW() + 2 days, but it has to be NOW() + (-2 days) $sinceLastScan = "-$sinceLastScan"; } try { // Ensure it's a valid date time string representation. new DateTime($sinceLastScan); $this->sinceLastScan = $sinceLastScan; } catch (Exception $_) { throw new InvalidArgumentException(sprintf( 'The specified last scan time is in an unknown format: %s', $time )); } } return $this; } /** * Get the targets since last scan threshold * * @return ?DateTime */ public function getSinceLastScan(): ?DateTime { if (! $this->sinceLastScan) { return null; } return new DateTime($this->sinceLastScan); } /** * Get the schedule config of this job * * @return Schedule */ public function getSchedule(): Schedule { if (! $this->schedule) { throw new LogicException('You are accessing an unset property. Please make sure to set it beforehand.'); } return $this->schedule; } /** * Set the schedule config of this job * * @param Schedule $schedule * * @return $this */ public function setSchedule(Schedule $schedule): self { $this->schedule = $schedule; /** @var stdClass $config */ $config = $schedule->getConfig(); $this->setFullScan($config->full_scan ?? false); $this->setRescan($config->rescan ?? false); $this->setLastScan($config->since_last_scan ?? Job::DEFAULT_SINCE_LAST_SCAN); return $this; } }