class OnceProp implements Onceable

Traits

Properties

protected bool $once

Indicates if the prop should be resolved only once.

from  ResolvesOnce
protected bool $refresh

Indicates if the prop should be forcefully refreshed.

from  ResolvesOnce
protected int|null $ttl

The expiration time in seconds.

from  ResolvesOnce
protected string|null $key

The custom key for resolving the once prop.

from  ResolvesOnce
protected callable $callback

The callback to resolve the property.

Methods

mixed
resolveCallable(mixed $value)

Call the given value if callable and inject its dependencies.

bool
useAsCallable(mixed $value)

Determine if the given value is callable, but not a string.

int
secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

once(bool $value = true, string|null $as = null, DateTimeInterface|DateInterval|int|null $until = null)

Mark the prop to be resolved only once.

bool
shouldResolveOnce()

Determine if the prop should be resolved only once.

bool
shouldBeRefreshed()

Determine if the prop should be forcefully refreshed.

string|null
getKey()

Get the custom key for resolving the once prop.

as(BackedEnum|UnitEnum|string $key)

Set a custom key for resolving the once prop.

fresh(bool $value = true)

Mark the property to be forcefully sent to the client.

until(DateTimeInterface|DateInterval|int $delay)

Set the expiration for the once prop.

int|null
expiresAt()

Get the expiration timestamp in milliseconds for the once prop.

__construct(callable $callback)

Create a new once property instance.

mixed
__invoke()

Resolve the property value.

Details

in ResolvesCallables at line 14
protected mixed resolveCallable(mixed $value)

Call the given value if callable and inject its dependencies.

Parameters

mixed $value

Return Value

mixed

in ResolvesCallables at line 22
protected bool useAsCallable(mixed $value)

Determine if the given value is callable, but not a string.

Parameters

mixed $value

Return Value

bool

in InteractsWithTime at line 17
protected int secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateInterval|DateTimeInterface|int $delay

Return Value

int

in InteractsWithTime at line 29
protected int availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

int

in InteractsWithTime at line 41
protected DateTimeInterface|int parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

DateTimeInterface|int

in InteractsWithTime at line 57
protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

in InteractsWithTime at line 65
protected string runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

Parameters

float $startTime
float|null $endTime

Return Value

string

in ResolvesOnce at line 40
ResolvesOnce once(bool $value = true, string|null $as = null, DateTimeInterface|DateInterval|int|null $until = null)

Mark the prop to be resolved only once.

Parameters

bool $value
string|null $as
DateTimeInterface|DateInterval|int|null $until

Return Value

ResolvesOnce

in ResolvesOnce at line 58
bool shouldResolveOnce()

Determine if the prop should be resolved only once.

Return Value

bool

in ResolvesOnce at line 66
bool shouldBeRefreshed()

Determine if the prop should be forcefully refreshed.

Return Value

bool

in ResolvesOnce at line 74
string|null getKey()

Get the custom key for resolving the once prop.

Return Value

string|null

in ResolvesOnce at line 82
ResolvesOnce as(BackedEnum|UnitEnum|string $key)

Set a custom key for resolving the once prop.

Parameters

BackedEnum|UnitEnum|string $key

Return Value

ResolvesOnce

in ResolvesOnce at line 96
ResolvesOnce fresh(bool $value = true)

Mark the property to be forcefully sent to the client.

Parameters

bool $value

Return Value

ResolvesOnce

in ResolvesOnce at line 106
ResolvesOnce until(DateTimeInterface|DateInterval|int $delay)

Set the expiration for the once prop.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

ResolvesOnce

in ResolvesOnce at line 116
int|null expiresAt()

Get the expiration timestamp in milliseconds for the once prop.

Return Value

int|null

at line 22
__construct(callable $callback)

Create a new once property instance.

Parameters

callable $callback

at line 31
mixed __invoke()

Resolve the property value.

Return Value

mixed