public function getVariationForFeatureExperiment(FeatureFlag $featureFlag, $userId, $userAttributes)
    {
        $featureFlagKey = $featureFlag->getKey();
        $experimentIds = $featureFlag->getExperimentIds();

        // Check if there are any experiment IDs inside feature flag
        if (empty($experimentIds)) {
            $this->_logger->log(
                Logger::DEBUG,
                "The feature flag '{$featureFlagKey}' is not used in any experiments."
            );
            return null;
        }

        // Evaluate each experiment ID and return the first bucketed experiment variation
        foreach ($experimentIds as $experiment_id) {
            $experiment = $this->_projectConfig->getExperimentFromId($experiment_id);
            if ($experiment && !($experiment->getKey())) {
                // Error logged and exception thrown in ProjectConfig-getExperimentFromId
                continue;
            }

            $variation = $this->getVariation($experiment, $userId, $userAttributes);
            if ($variation && $variation->getKey()) {
                $this->_logger->log(
                    Logger::INFO,
                    "The user '{$userId}' is bucketed into experiment '{$experiment->getKey()}' of feature '{$featureFlagKey}'."
                );

                return new FeatureDecision($experiment, $variation, FeatureDecision::DECISION_SOURCE_FEATURE_TEST);
            }
        }

        $this->_logger->log(
            Logger::INFO,
            "The user '{$userId}' is not bucketed into any of the experiments using the feature '{$featureFlagKey}'."
        );

        return null;
    }
public function getVariationForFeatureExperiment(FeatureFlag $featureFlag, $userId, $userAttributes)
    {
        $featureFlagKey = $featureFlag->getKey();
        $experimentIds = $featureFlag->getExperimentIds();

        // Check if there are any experiment IDs inside feature flag
        if (empty($experimentIds)) {
            $this->_logger->log(
                Logger::DEBUG,
                "The feature flag '{$featureFlagKey}' is not used in any experiments."
            );
            return null;
        }

        // Evaluate each experiment ID and return the first bucketed experiment variation
        foreach ($experimentIds as $experiment_id) {
            $experiment = $this->_projectConfig->getExperimentFromId($experiment_id);
            if ($experiment && !($experiment->getKey())) {
                // Error logged and exception thrown in ProjectConfig-getExperimentFromId
                continue;
            }

            $variation = $this->getVariation($experiment, $userId, $userAttributes);
            if ($variation && $variation->getKey()) {
                $this->_logger->log(
                    Logger::INFO,
                    "The user '{$userId}' is bucketed into experiment '{$experiment->getKey()}' of feature '{$featureFlagKey}'."
                );

                return new FeatureDecision($experiment, $variation, FeatureDecision::DECISION_SOURCE_FEATURE_TEST);
            }
        }

        $this->_logger->log(
            Logger::INFO,
            "The user '{$userId}' is not bucketed into any of the experiments using the feature '{$featureFlagKey}'."
        );

        return null;
    }
public function getVariationForFeatureExperiment ( FeatureFlag $ featureFlag , $ userId , $ userAttributes ) { $ featureFlagKey = $ featureFlag -> getKey ( ) ; $ experimentIds = $ featureFlag -> getExperimentIds ( ) ; // Check if there are any experiment IDs inside feature flag if ( empty ( $ experimentIds ) ) { $ this -> _logger -> log ( Logger :: DEBUG , "The feature flag '{$featureFlagKey}' is not used in any experiments." ) ; return null ; } // Evaluate each experiment ID and return the first bucketed experiment variation foreach ( $ experimentIds as $ experiment_id ) { $ experiment = $ this -> _projectConfig -> getExperimentFromId ( $ experiment_id ) ; if ( $ experiment && ! ( $ experiment -> getKey ( ) ) ) { // Error logged and exception thrown in ProjectConfig-getExperimentFromId continue ; } $ variation = $ this -> getVariation ( $ experiment , $ userId , $ userAttributes ) ; if ( $ variation && $ variation -> getKey ( ) ) { $ this -> _logger -> log ( Logger :: INFO , "The user '{$userId}' is bucketed into experiment '{$experiment->getKey()}' of feature '{$featureFlagKey}'." ) ; return new FeatureDecision ( $ experiment , $ variation , FeatureDecision :: DECISION_SOURCE_FEATURE_TEST ) ; } } $ this -> _logger -> log ( Logger :: INFO , "The user '{$userId}' is not bucketed into any of the experiments using the feature '{$featureFlagKey}'." ) ; return null ; }
Get the variation if the user is bucketed for one of the experiments on this feature flag

@param  FeatureFlag $featureFlag    The feature flag the user wants to access
@param  string      $userId         user id
@param  array       $userAttributes user userAttributes
@return Decision  if a variation is returned for the user
null  if feature flag is not used in any experiments or no variation is returned for the user
Get the variation if the user is bucketed for one of the experiments on this feature flag