public function getVariation($experimentKey, $userId, $attributes = null)
    {
        if (!$this->_isValid) {
            $this->_logger->log(Logger::ERROR, 'Datafile has invalid format. Failing "getVariation".');
            return null;
        }

        if (!$this->validateInputs(
            [
                self::EXPERIMENT_KEY =>$experimentKey,
                self::USER_ID => $userId
            ]
        )
        ) {
            return null;
        }

        $experiment = $this->_config->getExperimentFromKey($experimentKey);

        if (is_null($experiment->getKey())) {
            return null;
        }

        if (!$this->validateUserInputs($attributes)) {
            return null;
        }

        $variation = $this->_decisionService->getVariation($experiment, $userId, $attributes);
        $variationKey = ($variation === null) ? null : $variation->getKey();

        if ($this->_config->isFeatureExperiment($experiment->getId())) {
            $decisionNotificationType = DecisionNotificationTypes::FEATURE_TEST;
        } else {
            $decisionNotificationType = DecisionNotificationTypes::AB_TEST;
        }

        $attributes = $attributes ?: [];
        $this->notificationCenter->sendNotifications(
            NotificationType::DECISION,
            array(
                $decisionNotificationType,
                $userId,
                $attributes,
                (object) array(
                    'experimentKey'=> $experiment->getKey(),
                    'variationKey'=> $variationKey
                )
            )
        );

        return $variationKey;
    }
public function getVariation($experimentKey, $userId, $attributes = null)
    {
        if (!$this->_isValid) {
            $this->_logger->log(Logger::ERROR, 'Datafile has invalid format. Failing "getVariation".');
            return null;
        }

        if (!$this->validateInputs(
            [
                self::EXPERIMENT_KEY =>$experimentKey,
                self::USER_ID => $userId
            ]
        )
        ) {
            return null;
        }

        $experiment = $this->_config->getExperimentFromKey($experimentKey);

        if (is_null($experiment->getKey())) {
            return null;
        }

        if (!$this->validateUserInputs($attributes)) {
            return null;
        }

        $variation = $this->_decisionService->getVariation($experiment, $userId, $attributes);
        $variationKey = ($variation === null) ? null : $variation->getKey();

        if ($this->_config->isFeatureExperiment($experiment->getId())) {
            $decisionNotificationType = DecisionNotificationTypes::FEATURE_TEST;
        } else {
            $decisionNotificationType = DecisionNotificationTypes::AB_TEST;
        }

        $attributes = $attributes ?: [];
        $this->notificationCenter->sendNotifications(
            NotificationType::DECISION,
            array(
                $decisionNotificationType,
                $userId,
                $attributes,
                (object) array(
                    'experimentKey'=> $experiment->getKey(),
                    'variationKey'=> $variationKey
                )
            )
        );

        return $variationKey;
    }
public function getVariation ( $ experimentKey , $ userId , $ attributes = null ) { if ( ! $ this -> _isValid ) { $ this -> _logger -> log ( Logger :: ERROR , 'Datafile has invalid format. Failing "getVariation".' ) ; return null ; } if ( ! $ this -> validateInputs ( [ self :: EXPERIMENT_KEY => $ experimentKey , self :: USER_ID => $ userId ] ) ) { return null ; } $ experiment = $ this -> _config -> getExperimentFromKey ( $ experimentKey ) ; if ( is_null ( $ experiment -> getKey ( ) ) ) { return null ; } if ( ! $ this -> validateUserInputs ( $ attributes ) ) { return null ; } $ variation = $ this -> _decisionService -> getVariation ( $ experiment , $ userId , $ attributes ) ; $ variationKey = ( $ variation === null ) ? null : $ variation -> getKey ( ) ; if ( $ this -> _config -> isFeatureExperiment ( $ experiment -> getId ( ) ) ) { $ decisionNotificationType = DecisionNotificationTypes :: FEATURE_TEST ; } else { $ decisionNotificationType = DecisionNotificationTypes :: AB_TEST ; } $ attributes = $ attributes ? : [ ] ; $ this -> notificationCenter -> sendNotifications ( NotificationType :: DECISION , array ( $ decisionNotificationType , $ userId , $ attributes , ( object ) array ( 'experimentKey' => $ experiment -> getKey ( ) , 'variationKey' => $ variationKey ) ) ) ; return $ variationKey ; }
Get variation where user will be bucketed.

@param $experimentKey string Key identifying the experiment.
@param $userId string ID for user.
@param $attributes array Attributes of the user.

@return null|string Representing the variation key.
Get variation where user will be bucketed .