class MergeProp implements Mergeable, Onceable

Traits

Properties

protected bool $merge

Indicates if the property should be merged.

from  MergesProps
protected bool $deepMerge

Indicates if the property should be deep merged.

from  MergesProps
protected array<int, string> $matchOn

The properties to match on for merging.

from  MergesProps
protected bool $append

Indicates if the property values should be appended or prepended.

from  MergesProps
protected array<int, string> $appendsAtPaths

The paths to append.

from  MergesProps
protected array<int, string> $prependsAtPaths

The paths to prepend.

from  MergesProps
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 mixed $value

The property value.

Methods

merge()

Mark the property for merging.

deepMerge()

Mark the property for deep merging.

matchOn(string|array $matchOn)

Set the properties to match on for merging.

bool
shouldMerge()

Determine if the property should be merged.

bool
shouldDeepMerge()

Determine if the property should be deep merged.

array
matchesOn()

Get the properties to match on for merging.

bool
appendsAtRoot()

Determine if the property should be appended at the root level.

bool
prependsAtRoot()

Determine if the property should be prepended at the root level.

bool
mergesAtRoot()

Determine if the property merges at the root level.

append(bool|string|array $path = true, string|null $matchOn = null)

Specify that the value should be appended, optionally providing a key to append and a property to match on.

prepend(bool|string|array $path = true, string|null $matchOn = null)

Specify that the value should be prepended, optionally providing a key to prepend and a property to match on.

array
appendsAtPaths()

Get the paths to append.

array
prependsAtPaths()

Get the paths to prepend.

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(mixed $value)

Create a new merge property instance. Merge properties are combined with existing client-side data during partial reloads instead of completely replacing the property value.

mixed
__invoke()

Resolve the property value.

Details

in MergesProps at line 50
MergesProps merge()

Mark the property for merging.

Return Value

MergesProps

in MergesProps at line 60
MergesProps deepMerge()

Mark the property for deep merging.

Return Value

MergesProps

in MergesProps at line 72
MergesProps matchOn(string|array $matchOn)

Set the properties to match on for merging.

Parameters

string|array $matchOn

Return Value

MergesProps

in MergesProps at line 82
bool shouldMerge()

Determine if the property should be merged.

Return Value

bool

in MergesProps at line 90
bool shouldDeepMerge()

Determine if the property should be deep merged.

Return Value

bool

in MergesProps at line 100
array matchesOn()

Get the properties to match on for merging.

Return Value

array

in MergesProps at line 108
bool appendsAtRoot()

Determine if the property should be appended at the root level.

Return Value

bool

in MergesProps at line 116
bool prependsAtRoot()

Determine if the property should be prepended at the root level.

Return Value

bool

in MergesProps at line 124
protected bool mergesAtRoot()

Determine if the property merges at the root level.

Return Value

bool

in MergesProps at line 134
MergesProps append(bool|string|array $path = true, string|null $matchOn = null)

Specify that the value should be appended, optionally providing a key to append and a property to match on.

Parameters

bool|string|array $path
string|null $matchOn

Return Value

MergesProps

in MergesProps at line 156
MergesProps prepend(bool|string|array $path = true, string|null $matchOn = null)

Specify that the value should be prepended, optionally providing a key to prepend and a property to match on.

Parameters

bool|string|array $path
string|null $matchOn

Return Value

MergesProps

in MergesProps at line 178
array appendsAtPaths()

Get the paths to append.

Return Value

array

in MergesProps at line 188
array prependsAtPaths()

Get the paths to prepend.

Return Value

array

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 25
__construct(mixed $value)

Create a new merge property instance. Merge properties are combined with existing client-side data during partial reloads instead of completely replacing the property value.

Parameters

mixed $value

at line 34
mixed __invoke()

Resolve the property value.

Return Value

mixed