25
25
use Optimizely \DecisionService \FeatureDecision ;
26
26
use Optimizely \Entity \Experiment ;
27
27
use Optimizely \Entity \FeatureVariable ;
28
- use Optimizely \Logger \DefaultLogger ;
29
28
use Optimizely \ErrorHandler \ErrorHandlerInterface ;
30
29
use Optimizely \ErrorHandler \NoOpErrorHandler ;
31
30
use Optimizely \Event \Builder \EventBuilder ;
32
31
use Optimizely \Event \Dispatcher \DefaultEventDispatcher ;
33
32
use Optimizely \Event \Dispatcher \EventDispatcherInterface ;
33
+ use Optimizely \Logger \DefaultLogger ;
34
34
use Optimizely \Logger \LoggerInterface ;
35
35
use Optimizely \Logger \NoOpLogger ;
36
36
use Optimizely \Notification \NotificationCenter ;
@@ -479,18 +479,18 @@ public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
479
479
return false ;
480
480
}
481
481
482
- $ feature_flag = $ this ->_config ->getFeatureFlagFromKey ($ featureFlagKey );
483
- if ($ feature_flag && (!$ feature_flag ->getId ())) {
482
+ $ featureFlag = $ this ->_config ->getFeatureFlagFromKey ($ featureFlagKey );
483
+ if ($ featureFlag && (!$ featureFlag ->getId ())) {
484
484
// Error logged in ProjectConfig - getFeatureFlagFromKey
485
485
return false ;
486
486
}
487
487
488
488
//validate feature flag
489
- if (!Validator::isFeatureFlagValid ($ this ->_config , $ feature_flag )) {
489
+ if (!Validator::isFeatureFlagValid ($ this ->_config , $ featureFlag )) {
490
490
return false ;
491
491
}
492
492
493
- $ decision = $ this ->_decisionService ->getVariationForFeature ($ feature_flag , $ userId , $ attributes );
493
+ $ decision = $ this ->_decisionService ->getVariationForFeature ($ featureFlag , $ userId , $ attributes );
494
494
if (!$ decision ) {
495
495
$ this ->_logger ->log (Logger::INFO , "Feature Flag ' {$ featureFlagKey }' is not enabled for user ' {$ userId }'. " );
496
496
return false ;
@@ -574,8 +574,8 @@ public function getFeatureVariableValueForType(
574
574
return null ;
575
575
}
576
576
577
- $ feature_flag = $ this ->_config ->getFeatureFlagFromKey ($ featureFlagKey );
578
- if ($ feature_flag && (!$ feature_flag ->getId ())) {
577
+ $ featureFlag = $ this ->_config ->getFeatureFlagFromKey ($ featureFlagKey );
578
+ if ($ featureFlag && (!$ featureFlag ->getId ())) {
579
579
// Error logged in ProjectConfig - getFeatureFlagFromKey
580
580
return null ;
581
581
}
@@ -594,35 +594,35 @@ public function getFeatureVariableValueForType(
594
594
return null ;
595
595
}
596
596
597
- $ decision = $ this ->_decisionService ->getVariationForFeature ($ feature_flag , $ userId , $ attributes );
598
- $ variable_value = $ variable ->getDefaultValue ();
597
+ $ decision = $ this ->_decisionService ->getVariationForFeature ($ featureFlag , $ userId , $ attributes );
598
+ $ variableValue = $ variable ->getDefaultValue ();
599
599
600
600
if (!$ decision ) {
601
601
$ this ->_logger ->log (
602
602
Logger::INFO ,
603
603
"User ' {$ userId }'is not in any variation, " .
604
- "returning default value ' {$ variable_value }'. "
604
+ "returning default value ' {$ variableValue }'. "
605
605
);
606
606
} else {
607
607
$ variation = $ decision ->getVariation ();
608
608
$ variable_usage = $ variation ->getVariableUsageById ($ variable ->getId ());
609
609
if ($ variable_usage ) {
610
- $ variable_value = $ variable_usage ->getValue ();
610
+ $ variableValue = $ variable_usage ->getValue ();
611
611
$ this ->_logger ->log (
612
612
Logger::INFO ,
613
- "Returning variable value ' {$ variable_value }' for variation ' {$ variation ->getKey ()}' " .
613
+ "Returning variable value ' {$ variableValue }' for variation ' {$ variation ->getKey ()}' " .
614
614
"of feature flag ' {$ featureFlagKey }' "
615
615
);
616
616
} else {
617
617
$ this ->_logger ->log (
618
618
Logger::INFO ,
619
619
"Variable ' {$ variableKey }' is not used in variation ' {$ variation ->getKey ()}', " .
620
- "returning default value ' {$ variable_value }'. "
620
+ "returning default value ' {$ variableValue }'. "
621
621
);
622
622
}
623
623
}
624
624
625
- return $ variable_value ;
625
+ return $ variableValue ;
626
626
}
627
627
628
628
/**
@@ -637,19 +637,19 @@ public function getFeatureVariableValueForType(
637
637
*/
638
638
public function getFeatureVariableBoolean ($ featureFlagKey , $ variableKey , $ userId , $ attributes = null )
639
639
{
640
- $ variable_value = $ this ->getFeatureVariableValueForType (
640
+ $ variableValue = $ this ->getFeatureVariableValueForType (
641
641
$ featureFlagKey ,
642
642
$ variableKey ,
643
643
$ userId ,
644
644
$ attributes ,
645
645
FeatureVariable::BOOLEAN_TYPE
646
646
);
647
647
648
- if (!is_null ($ variable_value )) {
649
- return VariableTypeUtils::castStringToType ($ variable_value , FeatureVariable::BOOLEAN_TYPE , $ this ->_logger );
648
+ if (!is_null ($ variableValue )) {
649
+ return VariableTypeUtils::castStringToType ($ variableValue , FeatureVariable::BOOLEAN_TYPE , $ this ->_logger );
650
650
}
651
651
652
- return $ variable_value ;
652
+ return $ variableValue ;
653
653
}
654
654
655
655
/**
@@ -664,19 +664,19 @@ public function getFeatureVariableBoolean($featureFlagKey, $variableKey, $userId
664
664
*/
665
665
public function getFeatureVariableInteger ($ featureFlagKey , $ variableKey , $ userId , $ attributes = null )
666
666
{
667
- $ variable_value = $ this ->getFeatureVariableValueForType (
667
+ $ variableValue = $ this ->getFeatureVariableValueForType (
668
668
$ featureFlagKey ,
669
669
$ variableKey ,
670
670
$ userId ,
671
671
$ attributes ,
672
672
FeatureVariable::INTEGER_TYPE
673
673
);
674
674
675
- if (!is_null ($ variable_value )) {
676
- return VariableTypeUtils::castStringToType ($ variable_value , FeatureVariable::INTEGER_TYPE , $ this ->_logger );
675
+ if (!is_null ($ variableValue )) {
676
+ return VariableTypeUtils::castStringToType ($ variableValue , FeatureVariable::INTEGER_TYPE , $ this ->_logger );
677
677
}
678
678
679
- return $ variable_value ;
679
+ return $ variableValue ;
680
680
}
681
681
682
682
/**
@@ -691,19 +691,19 @@ public function getFeatureVariableInteger($featureFlagKey, $variableKey, $userId
691
691
*/
692
692
public function getFeatureVariableDouble ($ featureFlagKey , $ variableKey , $ userId , $ attributes = null )
693
693
{
694
- $ variable_value = $ this ->getFeatureVariableValueForType (
694
+ $ variableValue = $ this ->getFeatureVariableValueForType (
695
695
$ featureFlagKey ,
696
696
$ variableKey ,
697
697
$ userId ,
698
698
$ attributes ,
699
699
FeatureVariable::DOUBLE_TYPE
700
700
);
701
701
702
- if (!is_null ($ variable_value )) {
703
- return VariableTypeUtils::castStringToType ($ variable_value , FeatureVariable::DOUBLE_TYPE , $ this ->_logger );
702
+ if (!is_null ($ variableValue )) {
703
+ return VariableTypeUtils::castStringToType ($ variableValue , FeatureVariable::DOUBLE_TYPE , $ this ->_logger );
704
704
}
705
705
706
- return $ variable_value ;
706
+ return $ variableValue ;
707
707
}
708
708
709
709
/**
@@ -718,14 +718,14 @@ public function getFeatureVariableDouble($featureFlagKey, $variableKey, $userId,
718
718
*/
719
719
public function getFeatureVariableString ($ featureFlagKey , $ variableKey , $ userId , $ attributes = null )
720
720
{
721
- $ variable_value = $ this ->getFeatureVariableValueForType (
721
+ $ variableValue = $ this ->getFeatureVariableValueForType (
722
722
$ featureFlagKey ,
723
723
$ variableKey ,
724
724
$ userId ,
725
725
$ attributes ,
726
726
FeatureVariable::STRING_TYPE
727
727
);
728
728
729
- return $ variable_value ;
729
+ return $ variableValue ;
730
730
}
731
731
}
0 commit comments