SegmentVoter
extends AbstractVoter
in package
Voter for segment
Table of Contents
Properties
- $NAME : string
- $userProvider : UserProviderInterface
Methods
- __construct() : mixed
- getName() : string
- Get the name of the voter
- vote() : bool
- Vote whether an experiment should be applied based on the context
- compareValues() : bool
- Compare two values based on the comparison type
- evaluateCondition() : bool
- Evaluate a single condition against the context
- evaluateConditionGroup() : bool
- Evaluate a group of conditions (all conditions in a group are OR'd together)
- evaluateSegment() : bool
- Evaluate a segment against the context
- getContextParamClass() : string|null
- Get the context parameter class name based on parameter name
- getContextValue() : mixed|null
- Get the value from context based on parameter name
- groupConditionsByOperator() : array<string|int, mixed>
- Group conditions by operator precedence OR conditions are grouped together, AND creates new groups
- matchesRegex() : bool
- Safely match a value against a regex pattern Automatically adds delimiters if they're missing
Properties
$NAME
protected
static string
$NAME
= 'segment'
$userProvider
private
UserProviderInterface
$userProvider
Methods
__construct()
public
__construct(UserProviderInterface $userProvider) : mixed
Parameters
- $userProvider : UserProviderInterface
getName()
Get the name of the voter
public
getName() : string
Return values
stringvote()
Vote whether an experiment should be applied based on the context
public
vote(Context $context, Experiment $experiment) : bool
Parameters
- $context : Context
- $experiment : Experiment
Return values
boolcompareValues()
Compare two values based on the comparison type
private
compareValues(mixed $value1, mixed $value2[, string|null $type = null ]) : bool
Parameters
- $value1 : mixed
- $value2 : mixed
- $type : string|null = null
Return values
boolevaluateCondition()
Evaluate a single condition against the context
private
evaluateCondition(Context $context, array<string|int, mixed> $condition) : bool
Parameters
- $context : Context
- $condition : array<string|int, mixed>
Return values
boolevaluateConditionGroup()
Evaluate a group of conditions (all conditions in a group are OR'd together)
private
evaluateConditionGroup(Context $context, array<string|int, mixed> $group) : bool
Parameters
- $context : Context
- $group : array<string|int, mixed>
Return values
boolevaluateSegment()
Evaluate a segment against the context
private
evaluateSegment(Context $context, array<string|int, mixed> $segment) : bool
Parameters
- $context : Context
- $segment : array<string|int, mixed>
Return values
boolgetContextParamClass()
Get the context parameter class name based on parameter name
private
getContextParamClass(string $parameter[, Context|null $context = null ]) : string|null
Parameters
- $parameter : string
- $context : Context|null = null
-
Optional context for building the mapping
Return values
string|nullgetContextValue()
Get the value from context based on parameter name
private
getContextValue(Context $context, array<string|int, mixed> $condition) : mixed|null
Parameters
- $context : Context
- $condition : array<string|int, mixed>
Return values
mixed|nullgroupConditionsByOperator()
Group conditions by operator precedence OR conditions are grouped together, AND creates new groups
private
groupConditionsByOperator(array<string|int, mixed> $segment) : array<string|int, mixed>
Parameters
- $segment : array<string|int, mixed>
Return values
array<string|int, mixed>matchesRegex()
Safely match a value against a regex pattern Automatically adds delimiters if they're missing
private
matchesRegex(string $value, string $pattern) : bool
Parameters
- $value : string
-
The value to test
- $pattern : string
-
The regex pattern