Skip to content

Callback

Methods

run

public run(): string|false

exec

Executes command.

private exec(callable $fn): string

Parameters:

Parameter Type Description
$fn callable

__toString

public __toString(): string

Inherited methods

cron

The Cron expression representing the task's frequency.

public cron(string $expression = '* * * * *'): self

Parameters:

Parameter Type Description
$expression string

Throws:


filtersPass

Determine if the filters pass.

public filtersPass(): bool

between

Schedule task to run between start and end time.

public between(string $startTime, string $endTime): self

Parameters:

Parameter Type Description
$startTime string
$endTime string

unlessBetween

Schedule task that doesn't fall between start and end time.

public unlessBetween(string $startTime, string $endTime): self

Parameters:

Parameter Type Description
$startTime string
$endTime string

inTimeInterval

Schedule task to run between start and end time.

private inTimeInterval(string $startTime, string $endTime): \Closure

Parameters:

Parameter Type Description
$startTime string
$endTime string

hourly

Schedule the task to run hourly.

public hourly(int|string $minute = 1): self

Parameters:

Parameter Type Description
$minute int|string

Throws:


daily

Schedule the task to run daily.

public daily(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


on

Schedule the task to run on a certain date.

public on(string $date): self

Parameters:

Parameter Type Description
$date string

Throws:


at

Schedule the command at a given time.

public at(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


dailyAt

Schedule the task to run daily at a given time (10:00, 19:30, etc).

public dailyAt(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


twiceDaily

Schedule the task to run twice daily.

public twiceDaily(int $first = 1, int $second = 13): self

Parameters:

Parameter Type Description
$first int First hour.
$second int Second hour.

Throws:


twiceDailyAt

Schedule the task to run twice daily at a given minute.

public twiceDailyAt(int $first = 1, int $second = 13, int $minute): self

Parameters:

Parameter Type Description
$first int First hour.
$second int Second hour.
$minute int Minute.

Throws:


weekdays

Schedule the task to run only on weekdays.

public weekdays(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


weekends

Schedule the task to run only on weekdays.

public weekends(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


mondays

Schedule the task to run only on Mondays.

public mondays(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


tuesdays

Schedule the task to run only on Tuesdays.

public tuesdays(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


wednesdays

Schedule the task to run only on Wednesdays.

public wednesdays(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


thursdays

Schedule the task to run only on Thursdays.

public thursdays(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


fridays

Schedule the task to run only on Fridays.

public fridays(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


saturdays

Schedule the task to run only on Saturdays.

public saturdays(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


sundays

Schedule the task to run only on Sundays.

public sundays(?string $time = null): self

Parameters:

Parameter Type Description
$time ?string

Throws:


weekly

Schedule the task to run weekly.

public weekly(): self

Throws:


weeklyOn

Schedule the task to run weekly on a given day and time.

public weeklyOn(int|string $day, string $time = '0:0'): self

Parameters:

Parameter Type Description
$day int|string
$time string

Throws:


monthly

Schedule the task to run monthly.

public monthly(): self

Throws:


monthlyOn

Schedule the task to run monthly on a given day and time.

public monthlyOn(int|string $dayOfMonth, string $time = '0:0'): self

Parameters:

Parameter Type Description
$dayOfMonth int|string
$time string

Throws:


lastDayOfTheMonth

Schedule the task to run monthly on a given day and time.

public lastDayOfTheMonth(string $time = '0:0'): self

Parameters:

Parameter Type Description
$time string

Throws:


quarterly

Schedule the task to run quarterly.

public quarterly(int|string|array $day = 1, ?string $time = null): self

Parameters:

Parameter Type Description
$day int|string|array
$time ?string

Throws:


yearly

Schedule the task to run yearly.

public yearly(): self

Throws:


yearlyOn

Schedule the task to run yearly.

public yearlyOn(int $month, int $day, ?string $time = null): self

Parameters:

Parameter Type Description
$month int
$day int
$time ?string

Throws:


days

Set the days of the week the command should run on.

public days(mixed $days): self

Parameters:

Parameter Type Description
$days mixed

Throws:


hour

Set hour for the cron job.

public hour(mixed $value): self

Parameters:

Parameter Type Description
$value mixed

Throws:


minute

Set minute for the cron job.

public minute(mixed $value): self

Parameters:

Parameter Type Description
$value mixed

Throws:


dayOfMonth

Set day of the month for the cron job.

public dayOfMonth(mixed $value): self

Parameters:

Parameter Type Description
$value mixed

Throws:


month

Set month for the cron job.

public month(mixed $value): self

Parameters:

Parameter Type Description
$value mixed

Throws:


dayOfWeek

Set dah of the week for the cron job.

public dayOfWeek(mixed $value): self

Parameters:

Parameter Type Description
$value mixed

Throws:


timezone

Set the timezone the date should be evaluated on.

public timezone(\DateTimeZone|string $timezone): $this

Parameters:

Parameter Type Description
$timezone \DateTimeZone|string

every

Another way to the frequency of the cron job.

public every(string|null $unit = null, float|int|null $value = null): self

Parameters:

Parameter Type Description
$unit string|null (minute, hour, day, month or weekday)
$value float|int|null

Throws:


everyMinute

Schedule task to run every minute of every $minute minutes.

public everyMinute(string|int $minute = 1): self

Parameters:

Parameter Type Description
$minute string|int

Throws:


everyHour

Schedule task to run every hour or every $hour hour and $minute minutes.

public everyHour(string|int $hour = 1, int $minute): self

Parameters:

Parameter Type Description
$hour string|int
$minute int

Throws:


expressionPasses

Determine if the Cron expression passes.

protected expressionPasses(string|\DateTimeZone|null $timezone = null): bool

Parameters:

Parameter Type Description
$timezone string|\DateTimeZone|null

Throws:


spliceIntoPosition

Splice the given value into the given position of the expression.

protected spliceIntoPosition(int $position, string $value): self

Parameters:

Parameter Type Description
$position int
$value string

Throws:


setDayOfWeek

Internal function used by the everyMonday, etc functions.

protected setDayOfWeek(int|string $day, ?string $time = null): self

Parameters:

Parameter Type Description
$day int|string
$time ?string

Throws:


parseTime

Parses a time string (like 4:08 pm) into minutes and hours.

protected parseTime(string $time): array

Parameters:

Parameter Type Description
$time string

__construct

public __construct(\Codefy\Framework\Scheduler\Mutex\Locker $mutex, callable|string $command, ?array $args = null, \DateTimeZone|string|null $timezone = null): mixed

Parameters:

Parameter Type Description
$mutex \Codefy\Framework\Scheduler\Mutex\Locker
$command callable|string
$args ?array
$timezone \DateTimeZone|string|null

mutexName

Unique name to use for a mutually exclusive lock.

public mutexName(): string

withArgs

Set arguments for the command.

public withArgs(array|null $args = null): \Codefy\Framework\Scheduler\Processor\BaseProcessor

Parameters:

Parameter Type Description
$args array|null

description

Set a command description.

public description(string $description): self

Parameters:

Parameter Type Description
$description string

runCommandInForeground

protected runCommandInForeground(): string

runCommandInBackground

protected runCommandInBackground(): string

runInForeground

Force the command to run in foreground.

public runInForeground(): self

canRunCommandInBackground

Check if the command can run in background.

public canRunCommandInBackground(): bool

callBeforeCallbacks

Call all the before callbacks for the command.

public callBeforeCallbacks(): void

callAfterCallbacks

Call all the after callbacks for the command.

public callAfterCallbacks(): void

when

Truth test to determine if a command should run when it is due.

public when(callable|bool $callback): self

Parameters:

Parameter Type Description
$callback callable|bool

skip

Truth test to determine if a command should run when it is due.

public skip(callable|bool $callback): self

Parameters:

Parameter Type Description
$callback callable|bool

before

Set a function to be called before a command is executed.

public before(callable $fn): self

Parameters:

Parameter Type Description
$fn callable

after

Set a function to be called after a command is executed.

public after(callable $fn): self

Parameters:

Parameter Type Description
$fn callable

then

Set a function to be called after a command is executed.

public then(callable $fn, bool $runInBackground = false): self

Parameters:

Parameter Type Description
$fn callable
$runInBackground bool

onlyOneInstance

Prevents commands from overlapping.

public onlyOneInstance(int $expiresAfter = 120): self

Parameters:

Parameter Type Description
$expiresAfter int The amount of time in seconds the mutex lock should live.

canRunOnlyOneInstance

Check if process con only have one instance.

public canRunOnlyOneInstance(): bool

maxRuntime

public maxRuntime(): int

getExpression

Gets the current cron expression for the task.

public getExpression(): ?string

isDue

Determine if the given command should run based on the Cron expression.

public isDue(string|\DateTimeZone|null $timeZone = null): bool

Parameters:

Parameter Type Description
$timeZone string|\DateTimeZone|null

Throws:


compile

Compile the Task command.

protected compile(): string

getCommand

Returns the command.

public getCommand(): callable|string


Automatically generated on 2025-10-13