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

__construct(string $name, Closure|null $partitionResolver, array $featureStateResolvers)

Create a new driver instance.

void
define(string $feature, callable $resolver)

Define an initial feature flag state resolver.

array
defined()

Retrieve the names of all defined features.

array
stored()

Retrieve the names of all stored features.

array
getAll(array $features)

Get multiple feature flag values.

mixed
get(string $feature, mixed $scope)

Retrieve a feature flag's value.

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.

mixed
resolveValue(string $feature, mixed $scope)

Determine the initial value for a given feature and scope.

void
set(string $feature, mixed $scope, mixed $value)

Set a feature flag's value.

void
setAll(array $features)

Set multiple feature flag values.

void
setForAllScopes(string $feature, mixed $value)

Set a feature flag's value for all scopes.

void
delete(string $feature, mixed $scope)

Delete a feature flag's value.

void
purge(array|null $features)

Purge the given feature from storage.

bool
missingResolver(string $feature)

Determine if the feature does not have a resolver available.

string
partitionKey()

Get the key of the store's current partition.

void
flushCache()

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.

Parameters

string $name
Closure|null $partitionResolver
array $featureStateResolvers

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.

Parameters

string $feature
callable $resolver

Return Value

void

at line 83
array defined()

Retrieve the names of all defined features.

Return Value

array

at line 94
array stored()

Retrieve the names of all stored features.

Return Value

array

at line 105
array getAll(array $features)

Get multiple feature flag values.

Parameters

array $features

Return Value

array

at line 125
mixed get(string $feature, mixed $scope)

Retrieve a feature flag's value.

Parameters

string $feature
mixed $scope

Return Value

mixed

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.

Parameters

PennantState $state
string $partition
string $feature
mixed $scope

Return Value

mixed

at line 153
protected mixed resolveValue(string $feature, mixed $scope)

Determine the initial value for a given feature and scope.

Parameters

string $feature
mixed $scope

Return Value

mixed

at line 169
void set(string $feature, mixed $scope, mixed $value)

Set a feature flag's value.

Parameters

string $feature
mixed $scope
mixed $value

Return Value

void

at line 179
void setAll(array $features)

Set multiple feature flag values.

Parameters

array $features

Return Value

void

at line 192
void setForAllScopes(string $feature, mixed $value)

Set a feature flag's value for all scopes.

Parameters

string $feature
mixed $value

Return Value

void

at line 205
void delete(string $feature, mixed $scope)

Delete a feature flag's value.

Parameters

string $feature
mixed $scope

Return Value

void

at line 213
void purge(array|null $features)

Purge the given feature from storage.

Parameters

array|null $features

Return Value

void

at line 230
protected bool missingResolver(string $feature)

Determine if the feature does not have a resolver available.

Parameters

string $feature

Return Value

bool

at line 238
protected string partitionKey()

Get the key of the store's current partition.

Return Value

string

at line 246
void flushCache()

Flush the resolved feature states.

Return Value

void