TestData
in package
implements
FeatureRequester
Interfaces, Classes, Traits and Enums
- FeatureRequester
- Interface for the component that retrieves feature flag data.
Table of Contents
- __construct() : mixed
- dataSource() : TestData
- Creates a new instance of the test data source
- flag() : FlagBuilder
- Creates or copies a `FlagBuilder` for building a test flag configuration.
- getAllFeatures() : array<string, FeatureFlag>|null
- Gets all feature flags.
- getFeature() : FeatureFlag|null
- Gets the configuration for a specific feature flag.
- getSegment() : Segment|null
- Gets the configuration for a specific user segment.
- update() : TestData
- Updates the test data with the specified flag configuration.
Methods
__construct()
public
__construct() : mixed
Return values
mixed —dataSource()
Creates a new instance of the test data source
public
dataSource() : TestData
Return values
TestData —a new configurable test data source
flag()
Creates or copies a `FlagBuilder` for building a test flag configuration.
public
flag(string $key) : FlagBuilder
If this flag key has already been defined in this TestData
instance, then the builder
starts with the same configuration that was last provided for this flag.
Otherwise, it starts with a new default configuration in which the flag has true
and
false
variations, is true
for all users when targeting is turned on and
false
otherwise, and currently has targeting turned on. You can change any of those
properties, and provide more complex behavior, using the FlagBuilder
methods.
Once you have set the desired configuration, pass the builder to update
.
Parameters
- $key : string
-
the flag key
Return values
FlagBuilder —the flag configuration builder object
getAllFeatures()
Gets all feature flags.
public
getAllFeatures() : array<string, FeatureFlag>|null
Return values
array<string, FeatureFlag>|null —The decoded FeatureFlags, or null if missing
getFeature()
Gets the configuration for a specific feature flag.
public
getFeature(string $key) : FeatureFlag|null
Parameters
- $key : string
-
feature key
Return values
FeatureFlag|null —The decoded FeatureFlag, or null if missing
getSegment()
Gets the configuration for a specific user segment.
public
getSegment(string $key) : Segment|null
Parameters
- $key : string
-
segment key
Return values
Segment|null —The decoded Segment, or null if missing
update()
Updates the test data with the specified flag configuration.
public
update(FlagBuilder $flagBuilder) : TestData
This has the same effect as if a flag were added or modified on the LaunchDarkly dashboard.
It immediately propagates the flag change to any LDClient
instance(s) that you have
already configured to use this TestData
. If no LDClient
has been started yet,
it simply adds this flag to the test data which will be provided to any LDClient
that
you subsequently configure.
Any subsequent changes to this FlagBuilder
instance do not affect the test data,
unless you call update(FlagBuilder)
again.
Parameters
- $flagBuilder : FlagBuilder
-
a flag configuration builder
Return values
TestData —the same TestData
instance