ArrayDriver
class ArrayDriver implements CanListStoredFeatures, CanSetManyFeaturesForScopes, Driver, HasFlushableCache
Properties
| protected string | $name | The store's name. |
|
| protected null|FeaturePartition | $partitionResolver | The resolver of the store's current partition. |
|
| protected array<string, callable(mixed): mixed> | $featureStateResolvers | The feature state resolvers. |
|
| protected stdClass | $unknownFeatureValue | The sentinel value for unknown features. |
Methods
Create a new driver instance.
Define an initial feature flag state resolver.
Retrieve the names of all defined features.
Retrieve the names of all stored features.
Get multiple feature flag values.
Retrieve a feature flag's value.
Retrieve a feature flag's value from the given state, resolving and storing it when missing.
Determine the initial value for a given feature and scope.
Set a feature flag's value.
Set multiple feature flag values.
Set a feature flag's value for all scopes.
Delete a feature flag's value.
Purge the given feature from storage.
Determine if the feature does not have a resolver available.
Get the key of the store's current partition.
Flush the resolved feature states.
Details
at line 55
__construct(string $name, Closure|null $partitionResolver, array $featureStateResolvers)
Create a new driver instance.
Resolved feature states live in the current coroutine's PennantState, so each request, job and child coroutine starts with its own values.
at line 72
void
define(string $feature, callable $resolver)
Define an initial feature flag state resolver.
On a shared store, the definition persists for the worker lifetime and applies to every subsequent request.
at line 83
array
defined()
Retrieve the names of all defined features.
at line 94
array
stored()
Retrieve the names of all stored features.
at line 105
array
getAll(array $features)
Get multiple feature flag values.
at line 125
mixed
get(string $feature, mixed $scope)
Retrieve a feature flag's value.
at line 133
protected mixed
retrieve(PennantState $state, string $partition, string $feature, mixed $scope)
Retrieve a feature flag's value from the given state, resolving and storing it when missing.
at line 153
protected mixed
resolveValue(string $feature, mixed $scope)
Determine the initial value for a given feature and scope.
at line 169
void
set(string $feature, mixed $scope, mixed $value)
Set a feature flag's value.
at line 179
void
setAll(array $features)
Set multiple feature flag values.
at line 192
void
setForAllScopes(string $feature, mixed $value)
Set a feature flag's value for all scopes.
at line 205
void
delete(string $feature, mixed $scope)
Delete a feature flag's value.
at line 213
void
purge(array|null $features)
Purge the given feature from storage.
at line 230
protected bool
missingResolver(string $feature)
Determine if the feature does not have a resolver available.
at line 238
protected string
partitionKey()
Get the key of the store's current partition.
at line 246
void
flushCache()
Flush the resolved feature states.