Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions src/Optimizely/Optimizely.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ public function getFeatureVariableValueForType(
}
}

if (!is_null($variableValue)) {
$variableValue = VariableTypeUtils::castStringToType($variableValue, $variableType, $this->_logger);
}

$attributes = $attributes ?: [];
$this->notificationCenter->sendNotifications(
NotificationType::DECISION,
Expand Down Expand Up @@ -719,19 +723,13 @@ public function getFeatureVariableValueForType(
*/
public function getFeatureVariableBoolean($featureFlagKey, $variableKey, $userId, $attributes = null)
{
$variableValue = $this->getFeatureVariableValueForType(
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::BOOLEAN_TYPE
);

if (!is_null($variableValue)) {
return VariableTypeUtils::castStringToType($variableValue, FeatureVariable::BOOLEAN_TYPE, $this->_logger);
}

return $variableValue;
}

/**
Expand All @@ -746,19 +744,13 @@ public function getFeatureVariableBoolean($featureFlagKey, $variableKey, $userId
*/
public function getFeatureVariableInteger($featureFlagKey, $variableKey, $userId, $attributes = null)
{
$variableValue = $this->getFeatureVariableValueForType(
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::INTEGER_TYPE
);

if (!is_null($variableValue)) {
return VariableTypeUtils::castStringToType($variableValue, FeatureVariable::INTEGER_TYPE, $this->_logger);
}

return $variableValue;
}

/**
Expand All @@ -773,19 +765,13 @@ public function getFeatureVariableInteger($featureFlagKey, $variableKey, $userId
*/
public function getFeatureVariableDouble($featureFlagKey, $variableKey, $userId, $attributes = null)
{
$variableValue = $this->getFeatureVariableValueForType(
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::DOUBLE_TYPE
);

if (!is_null($variableValue)) {
return VariableTypeUtils::castStringToType($variableValue, FeatureVariable::DOUBLE_TYPE, $this->_logger);
}

return $variableValue;
}

/**
Expand All @@ -800,15 +786,13 @@ public function getFeatureVariableDouble($featureFlagKey, $variableKey, $userId,
*/
public function getFeatureVariableString($featureFlagKey, $variableKey, $userId, $attributes = null)
{
$variableValue = $this->getFeatureVariableValueForType(
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::STRING_TYPE
);

return $variableValue;
}

/**
Expand Down
Loading