MergeProp
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
Set the properties to match on for merging.
Determine if the property should be appended at the root level.
Determine if the property should be prepended at the root level.
Specify that the value should be appended, optionally providing a key to append and a property to match on.
Specify that the value should be prepended, optionally providing a key to prepend and a property to match on.
Call the given value if callable and inject its dependencies.
Determine if the given value is callable, but not a string.
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Mark the prop to be resolved only once.
Set a custom key for resolving the once prop.
Mark the property to be forcefully sent to the client.
Get the expiration timestamp in milliseconds for the once prop.
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.
Resolve the property value.
Details
in
MergesProps at line 50
MergesProps
merge()
Mark the property for merging.
in
MergesProps at line 60
MergesProps
deepMerge()
Mark the property for deep merging.
in
MergesProps at line 72
MergesProps
matchOn(string|array $matchOn)
Set the properties to match on for merging.
in
MergesProps at line 82
bool
shouldMerge()
Determine if the property should be merged.
in
MergesProps at line 90
bool
shouldDeepMerge()
Determine if the property should be deep merged.
in
MergesProps at line 100
array
matchesOn()
Get the properties to match on for merging.
in
MergesProps at line 108
bool
appendsAtRoot()
Determine if the property should be appended at the root level.
in
MergesProps at line 116
bool
prependsAtRoot()
Determine if the property should be prepended at the root level.
in
MergesProps at line 124
protected bool
mergesAtRoot()
Determine if the property merges at the root level.
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.
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.
in
MergesProps at line 178
array
appendsAtPaths()
Get the paths to append.
in
MergesProps at line 188
array
prependsAtPaths()
Get the paths to prepend.
in
ResolvesCallables at line 14
protected mixed
resolveCallable(mixed $value)
Call the given value if callable and inject its dependencies.
in
ResolvesCallables at line 22
protected bool
useAsCallable(mixed $value)
Determine if the given value is callable, but not a string.
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
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.
in
InteractsWithTime at line 57
protected int
currentTime()
Get the current system time as a UNIX timestamp.
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.
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.
in
ResolvesOnce at line 58
bool
shouldResolveOnce()
Determine if the prop should be resolved only once.
in
ResolvesOnce at line 66
bool
shouldBeRefreshed()
Determine if the prop should be forcefully refreshed.
in
ResolvesOnce at line 74
string|null
getKey()
Get the custom key for resolving the once prop.
in
ResolvesOnce at line 82
ResolvesOnce
as(BackedEnum|UnitEnum|string $key)
Set a custom key for resolving the once prop.
in
ResolvesOnce at line 96
ResolvesOnce
fresh(bool $value = true)
Mark the property to be forcefully sent to the client.
in
ResolvesOnce at line 106
ResolvesOnce
until(DateTimeInterface|DateInterval|int $delay)
Set the expiration for the once prop.
in
ResolvesOnce at line 116
int|null
expiresAt()
Get the expiration timestamp in milliseconds for the once prop.
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.
at line 34
mixed
__invoke()
Resolve the property value.