LaunchDarkly PHP SDK 6.3.0

FeatureFlagsState
in package
implements JsonSerializable

A snapshot of the state of all feature flags with regard to a specific user.

This is generated by calling LDClient::allFlagsState().

Serializing this object to JSON using json_encode(), or the jsonSerialize() method, will produce the appropriate data structure for bootstrapping the LaunchDarkly JavaScript client. See the SDK reference guide on "Bootstrapping".

Interfaces, Classes, Traits and Enums

JsonSerializable

Table of Contents

getFlagReason()  : EvaluationReason|null
Returns the evaluation reason for an individual feature flag (as returned by variationDetail()) at the time the state was recorded.
getFlagValue()  : mixed
Returns the value of an individual feature flag at the time the state was recorded.
isValid()  : bool
Returns true if this object contains a valid snapshot of feature flag state, or false if the state could not be computed (for instance, because the client was offline or there was no user).
jsonSerialize()  : array<string|int, mixed>
Returns a JSON representation of the entire state map (as an associative array), in the format used by the LaunchDarkly JavaScript SDK.
toValuesMap()  : array<string|int, mixed>
Returns an associative array of flag keys to flag values.

Methods

getFlagReason()

Returns the evaluation reason for an individual feature flag (as returned by variationDetail()) at the time the state was recorded.

public getFlagReason(string $key) : EvaluationReason|null
Parameters
$key : string

the feature flag key

Tags
see
LDClient::variationDetail()
Return values
EvaluationReason|null

the evaluation reason; null if reasons were not recorded, or if there was no such flag

getFlagValue()

Returns the value of an individual feature flag at the time the state was recorded.

public getFlagValue(string $key) : mixed
Parameters
$key : string

the feature flag key

Return values
mixed

the flag's value; null if the flag returned the default value, or if there was no such flag

isValid()

Returns true if this object contains a valid snapshot of feature flag state, or false if the state could not be computed (for instance, because the client was offline or there was no user).

public isValid() : bool
Return values
bool

true if the state is valid

jsonSerialize()

Returns a JSON representation of the entire state map (as an associative array), in the format used by the LaunchDarkly JavaScript SDK.

public jsonSerialize() : array<string|int, mixed>

Use this method if you are passing data to the front end in order to "bootstrap" the JavaScript client.

Note that calling json_encode() on a FeatureFlagsState object will automatically use the jsonSerialize() method.

Return values
array<string|int, mixed>

an associative array suitable for passing as a JSON object

toValuesMap()

Returns an associative array of flag keys to flag values.

public toValuesMap() : array<string|int, mixed>

If a flag would have evaluated to the default value, its value will be null.

Do not use this method if you are passing data to the front end to "bootstrap" the JavaScript client. Instead, use jsonSerialize().

Return values
array<string|int, mixed>

an associative array of flag keys to JSON values

Search results