Skip to content

Commit

Permalink
fixes casting cron expression values to string
Browse files Browse the repository at this point in the history
  • Loading branch information
leobeal committed May 6, 2019
1 parent dcd0cd2 commit f22dc41
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/Jobs/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class Schedule
private $cron;
private $shouldRunOnOnlyOneServer = true;
private $canOverlap = false;
private $ttl = 60*30; // 30 minutes
private $ttl = 60 * 30; // 30 minutes

/**
* Schedule constructor.
* @param string $expression the default cron
*/
public function __construct(string $expression = "* * * * *")
public function __construct(string $expression = '* * * * *')
{
$this->cron = new CronExpression($expression, new FieldFactory());
}
Expand All @@ -29,7 +29,7 @@ public function __construct(string $expression = "* * * * *")
*/
public function atDay(int $day): self
{
$this->cron->setPart(2, $day);
$this->cron->setPart(2, (string)$day);
return $this;
}

Expand All @@ -40,7 +40,7 @@ public function atDay(int $day): self
*/
public function atHour(int $hour): self
{
$this->cron->setPart(1, $hour);
$this->cron->setPart(1, (string)$hour);
return $this;
}

Expand All @@ -51,7 +51,7 @@ public function atHour(int $hour): self
*/
public function atMinute(int $minutes): self
{
$this->cron->setPart(0, $minutes);
$this->cron->setPart(0, (string)$minutes);
return $this;
}

Expand Down Expand Up @@ -106,7 +106,7 @@ public function everyThirtyMinutes(): self
*/
public function hourly(): self
{
$this->cron->setPart(0, 0);
$this->cron->setPart(0, '0');
return $this;
}

Expand All @@ -116,9 +116,9 @@ public function hourly(): self
*/
public function daily(): self
{
$this->cron->setPart(2, "*");
$this->cron->setPart(1, 0);
$this->cron->setPart(0, 0);
$this->cron->setPart(2, '*');
$this->cron->setPart(1, '0');
$this->cron->setPart(0, '0');
return $this;
}

Expand All @@ -128,10 +128,10 @@ public function daily(): self
*/
public function monthly(): self
{
$this->cron->setPart(3, "*");
$this->cron->setPart(2, 1);
$this->cron->setPart(1, 0);
$this->cron->setPart(0, 0);
$this->cron->setPart(3, '*');
$this->cron->setPart(2, '1');
$this->cron->setPart(1, '0');
$this->cron->setPart(0, '0');
return $this;
}

Expand All @@ -141,7 +141,7 @@ public function monthly(): self
*/
public function onlyWeekDays(): self
{
$this->cron->setPart(4, "1-5");
$this->cron->setPart(4, '1-5');
return $this;
}

Expand All @@ -153,9 +153,9 @@ public function onlyWeekDays(): self
public function spliceIntoPosition($value, int $position): self
{
if ($value === 1) {
$expr = "*";
$expr = '*';
} else {
$expr = "*/" . intval($value);
$expr = '*/' . intval($value);
}

$this->cron->setPart($position, $expr);
Expand All @@ -178,7 +178,7 @@ public function getExpression(): string
return $this->cron->getExpression();
}

public function setExpression(string $expression = "* * * * *"): self
public function setExpression(string $expression = '* * * * *'): self
{
$this->cron->setExpression($expression);
return $this;
Expand All @@ -190,7 +190,7 @@ public function setExpression(string $expression = "* * * * *"): self
* @param string $timeZone
* @return bool
*/
public function isDue($currentTime = 'now', string $timeZone = "Europe/Berlin"): bool
public function isDue($currentTime = 'now', string $timeZone = 'Europe/Berlin'): bool
{
return $this->cron->isDue($currentTime, $timeZone);
}
Expand All @@ -201,7 +201,7 @@ public function isDue($currentTime = 'now', string $timeZone = "Europe/Berlin"):
* @param string $timeZone
* @return \DateTime
*/
public function getNextRunDate($currentTime = 'now', string $timeZone = "Europe/Berlin"): \DateTime
public function getNextRunDate($currentTime = 'now', string $timeZone = 'Europe/Berlin'): \DateTime
{
return $this->cron->getNextRunDate($currentTime, 0, false, $timeZone);
}
Expand Down

0 comments on commit f22dc41

Please sign in to comment.