gets the name of the variation to apply based on userdata and the service definition

@param \stdClass $userData   user data
@param \stdClass $variations variations as defined in schema

@return string|null the variation name or null if none
488332
private function getSchemaVariationName($userData, $variations)
    {
        foreach ($variations as $variationName => $expressions) {
            $results = array_map(
                function ($expression) use ($userData) {
                    return $this->jmesRuntime->__invoke($expression, $userData);
                },
                $expressions
            );

            $results = array_unique($results);

            if (count($results) == 1 && $results[0] === true) {
                return $variationName;
            }
        }

        return null;
    }
125700
protected function getUserInfo(string $username)
    {
        if (!isset($this->users[$username])) {
            return null;
        }

        return $this->users[$username];
    }
945805
protected function getSettablePropertyValue($userProperty, $user)
    {
        if (empty($userProperty)) {
            return $user;
        }

        try {
            $propertyAccessor = PropertyAccess::createPropertyAccessor();
            return $propertyAccessor->getValue($user, $userProperty);
        } catch (NoSuchPropertyException $e) {
            return $this->handleException($e);
        }
    }
1024112
public function getUsername()
    {
        if (!$this->hasEnabledUsername()) {
            return null;
        }
        $usernameClass = $this->usernameClass;
        $noInit = $usernameClass::buildNoInitModel();
        /* @var $noInit Username */
        return $this->hasOne($usernameClass, [$noInit->createdByAttribute => $this->guidAttribute]);
    }
101043
private function setupUserData($userData = array())
	{
		$returnable = array();

		foreach($userData as $key => $value)
		{
			switch($key)
			{
				case 'URL':
					// Remove shop domain
					$url = str_replace($this->_API['SHOP_DOMAIN'], '', $value);

					// Verify it contains /admin/
					if (strpos($url, '/admin/') !== 0)
					{
						$url = str_replace('//', '/', '/admin/' . preg_replace('/\/?admin\/?/', '', $url));
					}
					$returnable[$key] = $url;
					break;

				default:
					$returnable[$key] = $value;

			}
		}

		return $returnable;
	}
101563
def get_forced_variation(self, experiment_key, user_id):
    

    if user_id not in self.forced_variation_map:
      self.logger.debug('User "%s" is not in the forced variation map.' % user_id)
      return None

    experiment = self.get_experiment_from_key(experiment_key)
    if not experiment:
      # The invalid experiment key will be logged inside this call.
      return None

    experiment_to_variation_map = self.forced_variation_map.get(user_id)

    if not experiment_to_variation_map:
      self.logger.debug('No experiment "%s" mapped to user "%s" in the forced variation map.' % (
        experiment_key,
        user_id
      ))
      return None

    variation_id = experiment_to_variation_map.get(experiment.id)
    if variation_id is None:
      self.logger.debug(
        'No variation mapped to experiment "%s" in the forced variation map.' % experiment_key
      )
      return None

    variation = self.get_variation_from_id(experiment_key, variation_id)

    self.logger.debug('Variation "%s" is mapped to experiment "%s" and user "%s" in the forced variation map' % (
      variation.key,
      experiment_key,
      user_id
    ))
    return variation
727138
public function createToken(array $tokenData, $userId = null)
    {
        $userId = $this->_checkUserId($userId);
        return $this->getTokenLibrary()->createToken($tokenData, $userId);
    }
705742
public function UserQuery($SafeData = FALSE) {
      if ($SafeData) {
         $this->SQL->Select('u.UserID, u.Name, u.Photo, u.About, u.Gender, u.CountVisits, u.InviteUserID, u.DateFirstVisit, u.DateLastActive, u.DateInserted, u.DateUpdated, u.Score, u.Admin, u.Deleted, u.CountDiscussions, u.CountComments');
      } else {
         $this->SQL->Select('u.*');
      }
      $this->SQL->From('User u');
//      $this->SQL->Select('i.Name', '', 'InviteName')
//         ->From('User u')
//         ->Join('User as i', 'u.InviteUserID = i.UserID', 'left');
   }
568357
public function get(): UserData
    {
        $json = $this->client->performApiCallWithJsonResponse('get', '/user');
        return ResponseHandler::create($json, ResponseHandler::METHOD_USER)->handle();
    }
1230739
public function getForcedVariation($experimentKey, $userId)
    {

        if (!isset($this->_forcedVariationMap[$userId])) {
            $this->_logger->log(Logger::DEBUG, sprintf('User "%s" is not in the forced variation map.', $userId));
            return null;
        }

        $experimentToVariationMap = $this->_forcedVariationMap[$userId];
        $experimentId = $this->getExperimentFromKey($experimentKey)->getId();
        // check for null and empty string experiment ID
        if (strlen($experimentId) == 0) {
            // this case is logged in getExperimentFromKey
            return null;
        }

        if (!isset($experimentToVariationMap[$experimentId])) {
            $this->_logger->log(Logger::DEBUG, sprintf('No experiment "%s" mapped to user "%s" in the forced variation map.', $experimentKey, $userId));
            return null;
        }

        $variationId = $experimentToVariationMap[$experimentId];
        $variation = $this->getVariationFromId($experimentKey, $variationId);
        $variationKey = $variation->getKey();

        $this->_logger->log(Logger::DEBUG, sprintf('Variation "%s" is mapped to experiment "%s" and user "%s" in the forced variation map', $variationKey, $experimentKey, $userId));

        return $variation;
    }
193343
private function getUserCollectionRegistration(\collection $collection, $userData)
    {
        if (false === $this->userHasRequestedARegistrationOnCollection($collection, $userData)) {
            return null;
        }

        $userRegistration = igorw\get_in($userData, [$collection->get_sbas_id(), $collection->get_base_id()]);

        // sets collection name
        $userRegistration['coll-name'] = $collection->get_label($this->locale);
        // sets default type
        $userRegistration['type'] = 'active';

        // gets registration entity
        $registration = $userRegistration['registration'];

        // set registration type & return user registration
        $registrationStillExists = !is_null($registration);
        $registrationNoMoreExists = !$registrationStillExists;
        $isPending = $registrationStillExists && $registration->isPending() && !$registration->isRejected();
        $isRejected = $registrationStillExists && $registration->isRejected();
        $isDone = ($registrationNoMoreExists) || (!$isPending && !$isRejected);
        $isActive = (Boolean) $userRegistration['active'];
        $isTimeLimited = (Boolean) $userRegistration['time-limited'];
        $isNotTimeLimited = !$isTimeLimited;
        $isOnTime = (Boolean) $userRegistration['in-time'];
        $isOutDated = !$isOnTime;

        if (!$isActive) {
            $userRegistration['type'] = 'inactive';

            return $userRegistration;
        }

        if ($isDone) {
            $userRegistration['type'] = 'accepted';

            return $userRegistration;
        }

        if ($isRejected) {
            $userRegistration['type'] = 'rejected';

            return $userRegistration;
        }

        if ($isTimeLimited && $isOnTime && $isPending) {
            $userRegistration['type'] = 'in-time';

            return $userRegistration;
        }

        if ($isTimeLimited && $isOutDated && $isPending) {
            $userRegistration['type'] = 'out-dated';

            return  $userRegistration;
        }

        if ($isNotTimeLimited && $isPending) {
            $userRegistration['type'] = 'pending';

            return $userRegistration;
        }

        return $userRegistration;
    }
10285
public function getRequiredFields($variationName = null)
    {
        if (is_null($variationName)) {
            return $this->schema->required;
        }

        /* compose required fields based on variation */
        $requiredFields = $this->getRequiredFields();
        foreach ($this->schema->properties as $fieldName => $fieldAttributes) {
            $onVariation = $this->getOnVariaton($fieldName);

            if (is_object($onVariation) && isset($onVariation->{$variationName}->required)) {
                $thisRequired = $onVariation->{$variationName}->required;

                if ($thisRequired === true) {
                    $requiredFields[] = $fieldName;
                }

                if ($thisRequired === false) {
                    // see if its set
                    $fieldIndex = array_search($fieldName, $requiredFields);
                    if ($fieldName !== false) {
                        unset($requiredFields[$fieldIndex]);
                    }
                }
            }
        }

        return array_values(
            array_unique(
                $requiredFields
            )
        );
    }
157189
public function getName(){
		$result = null;
		if (isset($this->userInfo[$this->socialFieldsMap['name']])) {
			$result = $this->userInfo[$this->socialFieldsMap['name']];
			}
		return $result;
		}
488641
public function getVariationFromId($experimentKey, $variationId)
    {
        if (isset($this->_variationIdMap[$experimentKey])
            && isset($this->_variationIdMap[$experimentKey][$variationId])
        ) {
            return $this->_variationIdMap[$experimentKey][$variationId];
        }

        $this->_logger->log(
            Logger::ERROR,
            sprintf(
                'No variation ID "%s" defined in datafile for experiment "%s".',
                $variationId,
                $experimentKey
            )
        );
        $this->_errorHandler->handleError(new InvalidVariationException('Provided variation is not in datafile.'));
        return new Variation();
    }
1073722
public function getName(){
		$result = null;
		if (isset($this->userInfo['first_name']) && isset($this->userInfo['last_name'])) {
			$result = $this->userInfo['first_name'] . ' ' . $this->userInfo['last_name'];
			}
		elseif (isset($this->userInfo['first_name']) && !isset($this->userInfo['last_name'])) {
			$result = $this->userInfo['first_name'];
			}
		elseif (!isset($this->userInfo['first_name']) && isset($this->userInfo['last_name'])) {
			$result = $this->userInfo['last_name'];
			}
		return $result;
		}
1235588
public function getVariation(string $variation): ManyToManyRelation
    {
        if (isset($this->nested[$variation])) {
            return $this->nested[$variation];
        }

        if (!isset($this->schema[Record::MORPHED_ALIASES][$variation])) {
            throw new RelationException("Undefined morphed variation '{$variation}'");
        }

        $class = $this->schema[Record::MORPHED_ALIASES][$variation];

        $relation = new ManyToManyRelation(
            $class,
            $this->makeSchema($class),
            $this->orm,
            $this->orm->define($class, ORMInterface::R_ROLE_NAME)
        );

        return $this->nested[$variation] = $relation->withContext($this->parent, false);
    }
1106960
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;
    }