Skip to content

Commit

Permalink
Validate cron schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Aug 16, 2024
1 parent fcb1372 commit b8a2140
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
"php": ">=8.1",
"ext-mbstring": "*",
"dragonmantank/cron-expression": "^2.0 || ^3.0"
"dragonmantank/cron-expression": "^2.3 || ^3.0"
},
"require-dev": {
"infection/infection": "^0.27.11",
Expand Down
9 changes: 8 additions & 1 deletion src/CronJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@

namespace Setono\CronBuilder;

use Cron\CronExpression;

final class CronJob implements \Stringable
{
public readonly string $schedule;

public function __construct(
public readonly string $schedule,
string $schedule,
public readonly string $command,
public readonly ?string $description = null,
) {
new CronExpression($schedule);

$this->schedule = $schedule;
}

public function toString(): string
Expand Down

0 comments on commit b8a2140

Please sign in to comment.