private function getStoredVariation(Experiment $experiment, UserProfile $userProfile)
    {
        $experimentKey = $experiment->getKey();
        $userId = $userProfile->getUserId();
        $variationId = $userProfile->getVariationForExperiment($experiment->getId());

        if (is_null($variationId)) {
            $this->_logger->log(
                Logger::INFO,
                sprintf('No previously activated variation of experiment "%s" for user "%s" found in user profile.', $experimentKey, $userId)
            );
            return null;
        }

        if (!$this->_projectConfig->isVariationIdValid($experimentKey, $variationId)) {
            $this->_logger->log(
                Logger::INFO,
                sprintf(
                    'User "%s" was previously bucketed into variation with ID "%s" for experiment "%s", but no matching variation was found for that user. We will re-bucket the user.',
                    $userId,
                    $variationId,
                    $experimentKey
                )
            );
            return null;
        }

        $variation = $this->_projectConfig->getVariationFromId($experimentKey, $variationId);
        $this->_logger->log(
            Logger::INFO,
            sprintf(
                'Returning previously activated variation "%s" of experiment "%s" for user "%s" from user profile.',
                $variation->getKey(),
                $experimentKey,
                $userId
            )
        );
        return $variation;
    }
private function getStoredVariation(Experiment $experiment, UserProfile $userProfile)
    {
        $experimentKey = $experiment->getKey();
        $userId = $userProfile->getUserId();
        $variationId = $userProfile->getVariationForExperiment($experiment->getId());

        if (is_null($variationId)) {
            $this->_logger->log(
                Logger::INFO,
                sprintf('No previously activated variation of experiment "%s" for user "%s" found in user profile.', $experimentKey, $userId)
            );
            return null;
        }

        if (!$this->_projectConfig->isVariationIdValid($experimentKey, $variationId)) {
            $this->_logger->log(
                Logger::INFO,
                sprintf(
                    'User "%s" was previously bucketed into variation with ID "%s" for experiment "%s", but no matching variation was found for that user. We will re-bucket the user.',
                    $userId,
                    $variationId,
                    $experimentKey
                )
            );
            return null;
        }

        $variation = $this->_projectConfig->getVariationFromId($experimentKey, $variationId);
        $this->_logger->log(
            Logger::INFO,
            sprintf(
                'Returning previously activated variation "%s" of experiment "%s" for user "%s" from user profile.',
                $variation->getKey(),
                $experimentKey,
                $userId
            )
        );
        return $variation;
    }
private function getStoredVariation ( Experiment $ experiment , UserProfile $ userProfile ) { $ experimentKey = $ experiment -> getKey ( ) ; $ userId = $ userProfile -> getUserId ( ) ; $ variationId = $ userProfile -> getVariationForExperiment ( $ experiment -> getId ( ) ) ; if ( is_null ( $ variationId ) ) { $ this -> _logger -> log ( Logger :: INFO , sprintf ( 'No previously activated variation of experiment "%s" for user "%s" found in user profile.' , $ experimentKey , $ userId ) ) ; return null ; } if ( ! $ this -> _projectConfig -> isVariationIdValid ( $ experimentKey , $ variationId ) ) { $ this -> _logger -> log ( Logger :: INFO , sprintf ( 'User "%s" was previously bucketed into variation with ID "%s" for experiment "%s", but no matching variation was found for that user. We will re-bucket the user.' , $ userId , $ variationId , $ experimentKey ) ) ; return null ; } $ variation = $ this -> _projectConfig -> getVariationFromId ( $ experimentKey , $ variationId ) ; $ this -> _logger -> log ( Logger :: INFO , sprintf ( 'Returning previously activated variation "%s" of experiment "%s" for user "%s" from user profile.' , $ variation -> getKey ( ) , $ experimentKey , $ userId ) ) ; return $ variation ; }
Get the stored variation for the given experiment from the user profile.

@param $experiment  Experiment  The experiment for which we are getting the stored variation.
@param $userProfile UserProfile The user profile from which we are getting the stored variation.

@return null|Variation the stored variation or null if not found.
Get the stored variation for the given experiment from the user profile .