Skip to content

Commit

Permalink
minor: ensure task always provides a timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Mar 4, 2023
1 parent 6616591 commit 8565e22
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/Schedule/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,11 @@ abstract class Task

private const DEFAULT_EXPRESSION = '* * * * *';

/** @var string */
private $description;
private string $expression = self::DEFAULT_EXPRESSION;
private ?\DateTimeZone $timezone = null;

/** @var string */
private $expression = self::DEFAULT_EXPRESSION;

/** @var \DateTimeZone|null */
private $timezone;

public function __construct(string $description)
public function __construct(private string $description)
{
$this->description = $description;
}

final public function __toString(): string
Expand Down Expand Up @@ -749,8 +742,8 @@ private function spliceIntoPosition(int $position, $value, ...$values): self
return $this->cron(\implode(' ', $segments));
}

private function getTimezoneValue(): ?string
private function getTimezoneValue(): string
{
return $this->getTimezone() ? $this->getTimezone()->getName() : null;
return ($this->getTimezone() ?? new \DateTimeZone(\date_default_timezone_get()))->getName();
}
}

0 comments on commit 8565e22

Please sign in to comment.