class Fluent implements Arrayable, ArrayAccess, IteratorAggregate, Jsonable, JsonSerializable (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected $attributes

Methods

$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

array
all(mixed $keys = null)

Get all of the attributes from the fluent instance.

mixed
data(string $key = null, mixed $default = null)

Get data from the fluent instance.

bool
exists(string|array $key)

Determine if the data contains a given key.

bool
has(string|array $key)

Determine if the data contains a given key.

bool
hasAny(string|array $keys)

Determine if the instance contains any of the given keys.

$this|mixed
whenHas(string $key, callable $callback, callable|null $default = null)

Apply the callback if the instance contains the given key.

bool
filled(string|array $key)

Determine if the instance contains a non-empty value for the given key.

bool
isNotFilled(string|array $key)

Determine if the instance contains an empty value for the given key.

bool
anyFilled(string|array $keys)

Determine if the instance contains a non-empty value for any of the given keys.

$this|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.

bool
missing(string|array $key)

Determine if the instance is missing a given key.

$this|mixed
whenMissing(string $key, callable $callback, callable|null $default = null)

Apply the callback if the instance is missing the given key.

bool
isEmptyString(string $key)

Determine if the given key is an empty string for "filled".

str(string $key, mixed $default = null)

Retrieve data from the instance as a Stringable instance.

string(string $key, mixed $default = null)

Retrieve data from the instance as a Stringable instance.

bool
boolean(string|null $key = null, bool $default = false)

Retrieve data as a boolean value.

int
integer(string $key, int $default = 0)

Retrieve data as an integer value.

float
float(string $key, float $default = 0.0)

Retrieve data as a float value.

Carbon|null
date(string $key, string|null $format = null, UnitEnum|string|null $tz = null)

Retrieve data from the instance as a Carbon instance.

TEnum|null
enum(string $key, TEnum> $enumClass, TEnum|null $default = null)

Retrieve data from the instance as an enum.

TEnum[]
enums(string $key, TEnum> $enumClass)

Retrieve data from the instance as an array of enums.

bool
isBackedEnum(class-string $enumClass)

Determine if the given enum class is backed.

array
array(array|string|null $key = null)

Retrieve data from the instance as an array.

collect(array|string|null $key = null)

Retrieve data from the instance as a collection.

array
only(mixed $keys)

Get a subset containing the provided keys with values from the instance data.

array
except(mixed $keys)

Get all of the data except for a specified array of items.

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

$this
__call(TKey $method, $parameters)

Handle dynamic calls to the fluent instance to set attributes.

__construct(TValue> $attributes = [])

Create a new fluent instance.

static Fluent
make(TValue> $attributes = [])

Create a new fluent instance.

get($key, $default = null)

No description

$this
set(TKey $key, TValue $value)

Set an attribute on the fluent instance using "dot" notation.

$this
fill(TValue> $attributes)

Fill the fluent instance with an array of attributes.

mixed
value(string $key, mixed $default = null)

Get an attribute from the fluent instance.

scope(string $key, mixed $default = null)

Get the value of the given key as a new Fluent instance.

getAttributes()

No description

toArray()

No description

array
jsonSerialize()

No description

string
toJson(int $options = 0)

Convert the fluent instance to JSON.

string
toPrettyJson()

Convert the fluent instance to pretty print formatted JSON.

bool
isEmpty()

Determine if the fluent instance is empty.

bool
isNotEmpty()

Determine if the fluent instance is not empty.

bool
offsetExists(TKey $offset)

Determine if the given offset exists.

mixed
offsetGet(TKey $offset)

Get the value for a given offset.

void
offsetSet(TKey $offset, TValue $value)

Set the value at the given offset.

void
offsetUnset(TKey $offset)

Unset the value at the given offset.

getIterator()

Get an iterator for the attributes.

TValue|null
__get(TKey $key)

Dynamically retrieve the value of an attribute.

void
__set(TKey $key, TValue $value)

Dynamically set the value of an attribute.

bool
__isset(TKey $key)

Dynamically check if an attribute is set.

void
__unset(TKey $key)

Dynamically unset an attribute.

Details

$this|TWhenReturnType when($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

$value
callable|null $callback
callable|null $default

Return Value

$this|TWhenReturnType

$this|TUnlessReturnType unless($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

$value
callable|null $callback
callable|null $default

Return Value

$this|TUnlessReturnType

array all(mixed $keys = null)

Get all of the attributes from the fluent instance.

Parameters

mixed $keys

Return Value

array

protected mixed data(string $key = null, mixed $default = null)

Get data from the fluent instance.

Parameters

string $key
mixed $default

Return Value

mixed

bool exists(string|array $key)

Determine if the data contains a given key.

Parameters

string|array $key

Return Value

bool

bool has(string|array $key)

Determine if the data contains a given key.

Parameters

string|array $key

Return Value

bool

bool hasAny(string|array $keys)

Determine if the instance contains any of the given keys.

Parameters

string|array $keys

Return Value

bool

$this|mixed whenHas(string $key, callable $callback, callable|null $default = null)

Apply the callback if the instance contains the given key.

Parameters

string $key
callable $callback
callable|null $default

Return Value

$this|mixed

bool filled(string|array $key)

Determine if the instance contains a non-empty value for the given key.

Parameters

string|array $key

Return Value

bool

bool isNotFilled(string|array $key)

Determine if the instance contains an empty value for the given key.

Parameters

string|array $key

Return Value

bool

bool anyFilled(string|array $keys)

Determine if the instance contains a non-empty value for any of the given keys.

Parameters

string|array $keys

Return Value

bool

$this|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.

Parameters

string $key
callable $callback
callable|null $default

Return Value

$this|mixed

bool missing(string|array $key)

Determine if the instance is missing a given key.

Parameters

string|array $key

Return Value

bool

$this|mixed whenMissing(string $key, callable $callback, callable|null $default = null)

Apply the callback if the instance is missing the given key.

Parameters

string $key
callable $callback
callable|null $default

Return Value

$this|mixed

protected bool isEmptyString(string $key)

Determine if the given key is an empty string for "filled".

Parameters

string $key

Return Value

bool

Stringable str(string $key, mixed $default = null)

Retrieve data from the instance as a Stringable instance.

Parameters

string $key
mixed $default

Return Value

Stringable

Stringable string(string $key, mixed $default = null)

Retrieve data from the instance as a Stringable instance.

Parameters

string $key
mixed $default

Return Value

Stringable

bool boolean(string|null $key = null, bool $default = false)

Retrieve data as a boolean value.

Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.

Parameters

string|null $key
bool $default

Return Value

bool

int integer(string $key, int $default = 0)

Retrieve data as an integer value.

Parameters

string $key
int $default

Return Value

int

float float(string $key, float $default = 0.0)

Retrieve data as a float value.

Parameters

string $key
float $default

Return Value

float

Carbon|null date(string $key, string|null $format = null, UnitEnum|string|null $tz = null)

Retrieve data from the instance as a Carbon instance.

Parameters

string $key
string|null $format
UnitEnum|string|null $tz

Return Value

Carbon|null

Exceptions

InvalidFormatException

TEnum|null enum(string $key, TEnum> $enumClass, TEnum|null $default = null)

Retrieve data from the instance as an enum.

Parameters

string $key
TEnum> $enumClass
TEnum|null $default

Return Value

TEnum|null

TEnum[] enums(string $key, TEnum> $enumClass)

Retrieve data from the instance as an array of enums.

Parameters

string $key
TEnum> $enumClass

Return Value

TEnum[]

protected bool isBackedEnum(class-string $enumClass)

Determine if the given enum class is backed.

Parameters

class-string $enumClass

Return Value

bool

array array(array|string|null $key = null)

Retrieve data from the instance as an array.

Parameters

array|string|null $key

Return Value

array

Collection collect(array|string|null $key = null)

Retrieve data from the instance as a collection.

Parameters

array|string|null $key

Return Value

Collection

array only(mixed $keys)

Get a subset containing the provided keys with values from the instance data.

Parameters

mixed $keys

Return Value

array

array except(mixed $keys)

Get all of the data except for a specified array of items.

Parameters

mixed $keys

Return Value

array

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

$this __call(TKey $method, $parameters)

Handle dynamic calls to the fluent instance to set attributes.

Parameters

TKey $method
$parameters

Return Value

$this

__construct(TValue> $attributes = [])

Create a new fluent instance.

Parameters

TValue> $attributes

static Fluent make(TValue> $attributes = [])

Create a new fluent instance.

Parameters

TValue> $attributes

Return Value

Fluent

get($key, $default = null)

No description

Parameters

$key
$default

$this set(TKey $key, TValue $value)

Set an attribute on the fluent instance using "dot" notation.

Parameters

TKey $key
TValue $value

Return Value

$this

$this fill(TValue> $attributes)

Fill the fluent instance with an array of attributes.

Parameters

TValue> $attributes

Return Value

$this

mixed value(string $key, mixed $default = null)

Get an attribute from the fluent instance.

Parameters

string $key
mixed $default

Return Value

mixed

Fluent scope(string $key, mixed $default = null)

Get the value of the given key as a new Fluent instance.

Parameters

string $key
mixed $default

Return Value

Fluent

getAttributes()

No description

toArray()

No description

array jsonSerialize()

No description

Return Value

array

string toJson(int $options = 0)

Convert the fluent instance to JSON.

Parameters

int $options

Return Value

string

string toPrettyJson()

Convert the fluent instance to pretty print formatted JSON.

Return Value

string

bool isEmpty()

Determine if the fluent instance is empty.

Return Value

bool

bool isNotEmpty()

Determine if the fluent instance is not empty.

Return Value

bool

bool offsetExists(TKey $offset)

Determine if the given offset exists.

Parameters

TKey $offset

Return Value

bool

mixed offsetGet(TKey $offset)

Get the value for a given offset.

Parameters

TKey $offset

Return Value

mixed

void offsetSet(TKey $offset, TValue $value)

Set the value at the given offset.

Parameters

TKey $offset
TValue $value

Return Value

void

void offsetUnset(TKey $offset)

Unset the value at the given offset.

Parameters

TKey $offset

Return Value

void

Traversable getIterator()

Get an iterator for the attributes.

Return Value

Traversable

TValue|null __get(TKey $key)

Dynamically retrieve the value of an attribute.

Parameters

TKey $key

Return Value

TValue|null

void __set(TKey $key, TValue $value)

Dynamically set the value of an attribute.

Parameters

TKey $key
TValue $value

Return Value

void

bool __isset(TKey $key)

Dynamically check if an attribute is set.

Parameters

TKey $key

Return Value

bool

void __unset(TKey $key)

Dynamically unset an attribute.

Parameters

TKey $key

Return Value

void