diff --git a/src/Cron/AbstractField.php b/src/Cron/AbstractField.php index bc7de80e..cd2410ab 100644 --- a/src/Cron/AbstractField.php +++ b/src/Cron/AbstractField.php @@ -76,8 +76,13 @@ public function isInRange($dateValue, $value) public function isInIncrementsOfRanges($dateValue, $value) { $parts = array_map('trim', explode('/', $value, 2)); - $stepSize = isset($parts[1]) ? $parts[1] : 0; - if (($parts[0] == '*' || $parts[0] === '0') && 0 !== $stepSize) { + $stepSize = isset($parts[1]) ? (int) $parts[1] : 0; + + if ($stepSize === 0) { + return false; + } + + if (($parts[0] == '*' || $parts[0] === '0')) { return (int) $dateValue % $stepSize == 0; } diff --git a/tests/Cron/AbstractFieldTest.php b/tests/Cron/AbstractFieldTest.php index cb1abec8..5150d045 100644 --- a/tests/Cron/AbstractFieldTest.php +++ b/tests/Cron/AbstractFieldTest.php @@ -61,6 +61,8 @@ public function testTestsIfInIncrementsOfRanges() $this->assertFalse($f->isInIncrementsOfRanges(3, '2-59')); $this->assertFalse($f->isInIncrementsOfRanges(3, '2')); $this->assertFalse($f->isInIncrementsOfRanges(3, '*')); + $this->assertFalse($f->isInIncrementsOfRanges(0, '*/0')); + $this->assertFalse($f->isInIncrementsOfRanges(1, '*/0')); $this->assertTrue($f->isInIncrementsOfRanges(4, '4/10')); $this->assertTrue($f->isInIncrementsOfRanges(14, '4/10'));