Fluent
class Fluent implements Arrayable, ArrayAccess, IteratorAggregate, Jsonable, JsonSerializable, Transient
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected TValue> | $attributes | All of the attributes set on the fluent instance. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Get all of the attributes from the fluent instance.
Get data from the fluent instance.
Determine if the instance contains any of the given keys.
Apply the callback if the instance contains the given key.
Determine if the instance contains a non-empty value for the given key.
Determine if the instance contains an empty value for the given key.
Determine if the instance contains a non-empty value for any of the given keys.
Apply the callback if the instance contains a non-empty value for the given key.
Apply the callback if the instance contains a valid enum value for the given key.
Determine if the instance is missing a given key.
Apply the callback if the instance is missing the given key.
Determine if the given key is an empty string for "filled".
Retrieve data from the instance as a Stringable instance.
Retrieve data from the instance as a Stringable instance.
Retrieve data as a boolean value.
Retrieve data as an integer value.
Retrieve data as a float value.
Retrieve data clamped between min and max values.
Retrieve data from the instance as a Carbon instance.
Retrieve data from the instance as a CarbonInterval instance.
Retrieve data from the instance as an enum.
Retrieve data from the instance as an array of enums.
Retrieve data from the instance as an array.
Retrieve data from the instance as a collection.
Get a subset containing the provided keys with values from the instance data.
Get all of the data except for a specified array of items.
Mix another object into the class.
Dynamically handle calls to the class.
Handle dynamic calls to the fluent instance to set attributes.
Create a new fluent instance.
Get an attribute from the fluent instance using "dot" notation.
Set an attribute on the fluent instance using "dot" notation.
Get an attribute from the fluent instance.
Get the value of the given key as a new Fluent instance.
Get the attributes from the fluent instance.
Convert the fluent instance to an array.
Convert the object into something JSON serializable.
Convert the fluent instance to JSON.
Convert the fluent instance to pretty print formatted JSON.
Determine if the fluent instance is empty.
Determine if the fluent instance is not empty.
Determine if the given offset exists.
Get the value for a given offset.
Set the value at the given offset.
Unset the value at the given offset.
Get an iterator for the attributes.
Flush all static state.
Dynamically retrieve the value of an attribute.
Dynamically set the value of an attribute.
Dynamically check if an attribute is set.
Dynamically unset an attribute.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
at line 128
array
all(mixed $keys = null)
Get all of the attributes from the fluent instance.
at line 148
protected mixed
data(string|null $key = null, mixed $default = null)
Get data from the fluent instance.
in
InteractsWithData at line 40
bool
exists(array|string $key)
Determine if the data contains a given key.
in
InteractsWithData at line 48
bool
has(array|string $key)
Determine if the data contains a given key.
in
InteractsWithData at line 67
bool
hasAny(array|string $keys)
Determine if the instance contains any of the given keys.
in
InteractsWithData at line 86
mixed
whenHas(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance contains the given key.
in
InteractsWithData at line 102
bool
filled(array|string $key)
Determine if the instance contains a non-empty value for the given key.
in
InteractsWithData at line 119
bool
isNotFilled(array|string $key)
Determine if the instance contains an empty value for the given key.
in
InteractsWithData at line 136
bool
anyFilled(array|string $keys)
Determine if the instance contains a non-empty value for any of the given keys.
in
InteractsWithData at line 160
mixed
whenFilled(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance contains a non-empty value for the given key.
in
InteractsWithData at line 185
mixed
whenEnum(string $key, string $enumClass, callable $callback, callable|null $default = null)
Apply the callback if the instance contains a valid enum value for the given key.
in
InteractsWithData at line 201
bool
missing(array|string $key)
Determine if the instance is missing a given key.
in
InteractsWithData at line 218
mixed
whenMissing(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance is missing the given key.
in
InteractsWithData at line 234
protected bool
isEmptyString(string $key)
Determine if the given key is an empty string for "filled".
in
InteractsWithData at line 246
Stringable
str(string $key, mixed $default = null, bool $strict = false)
Retrieve data from the instance as a Stringable instance.
in
InteractsWithData at line 256
Stringable
string(string $key, mixed $default = null, bool $strict = false)
Retrieve data from the instance as a Stringable instance.
When strict, values that are not strings, numbers, or Stringable objects return the default.
in
InteractsWithData at line 279
bool|null
boolean(string|null $key = null, Closure|bool|null $default = false, bool $strict = false)
Retrieve data as a boolean value.
Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false. When strict, unrecognized or empty values return the default.
in
InteractsWithData at line 301
int|null
integer(string $key, Closure|int|null $default = 0, bool $strict = false)
Retrieve data as an integer value.
When strict, values that are not valid integers return the default.
in
InteractsWithData at line 328
float|null
float(string $key, Closure|float|null $default = 0.0, bool $strict = false)
Retrieve data as a float value.
When strict, values that are not valid numbers return the default.
in
InteractsWithData at line 347
int|float
clamp(string $key, int|float $min, int|float $max, int|float $default = 0)
Retrieve data clamped between min and max values.
in
InteractsWithData at line 365
CarbonInterface|null
date(string $key, string|null $format = null, UnitEnum|string|null $tz = null)
Retrieve data from the instance as a Carbon instance.
in
InteractsWithData at line 383
CarbonInterval|null
interval(string $key, Unit|string|null $unit = null)
Retrieve data from the instance as a CarbonInterval instance.
in
InteractsWithData at line 410
mixed
enum(string $key, string $enumClass, mixed $default = null)
Retrieve data from the instance as an enum.
in
InteractsWithData at line 427
array
enums(string $key, string $enumClass)
Retrieve data from the instance as an array of enums.
in
InteractsWithData at line 442
array
array(array|string|null $key = null)
Retrieve data from the instance as an array.
in
InteractsWithData at line 452
Collection
collect(array|string|null $key = null)
Retrieve data from the instance as a collection.
in
InteractsWithData at line 460
array
only(mixed $keys)
Get a subset containing the provided keys with values from the instance data.
in
InteractsWithData at line 482
array
except(mixed $keys)
Get all of the data except for a specified array of items.
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 284
mixed
__call(string $method, array $parameters)
Handle dynamic calls to the fluent instance to set attributes.
at line 46
__construct(array|object $attributes = [])
Create a new fluent instance.
at line 56
static Fluent
make(array|object $attributes = [])
Create a new fluent instance.
at line 69
mixed
get(string|int|null $key = null, mixed $default = null)
Get an attribute from the fluent instance using "dot" notation.
at line 79
Fluent
set(string|int $key, mixed $value)
Set an attribute on the fluent instance using "dot" notation.
at line 92
Fluent
fill(array|object $attributes)
Fill the fluent instance with an array of attributes.
at line 104
mixed
value(string|int $key, mixed $default = null)
Get an attribute from the fluent instance.
at line 116
Fluent
scope(string $key, mixed $default = null)
Get the value of the given key as a new Fluent instance.
at line 158
array
getAttributes()
Get the attributes from the fluent instance.
at line 168
array
toArray()
Convert the fluent instance to an array.
at line 178
array
jsonSerialize()
Convert the object into something JSON serializable.
at line 188
string
toJson(int $options = 0)
Convert the fluent instance to JSON.
at line 198
string
toPrettyJson(int $options = 0)
Convert the fluent instance to pretty print formatted JSON.
at line 206
bool
isEmpty()
Determine if the fluent instance is empty.
at line 214
bool
isNotEmpty()
Determine if the fluent instance is not empty.
at line 224
bool
offsetExists(mixed $offset)
Determine if the given offset exists.
at line 235
mixed
offsetGet(mixed $offset)
Get the value for a given offset.
at line 246
void
offsetSet(mixed $offset, mixed $value)
Set the value at the given offset.
at line 256
void
offsetUnset(mixed $offset)
Unset the value at the given offset.
at line 266
Traversable
getIterator()
Get an iterator for the attributes.
at line 274
static void
flushState()
Flush all static state.
at line 300
mixed
__get(string $key)
Dynamically retrieve the value of an attribute.
at line 308
void
__set(string $key, mixed $value)
Dynamically set the value of an attribute.
at line 316
bool
__isset(string $key)
Dynamically check if an attribute is set.
at line 324
void
__unset(string $key)
Dynamically unset an attribute.