repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
optimizely/php-sdk | src/Optimizely/ProjectConfig.php | ProjectConfig.getAudience | public function getAudience($audienceId)
{
if (isset($this->_audienceIdMap[$audienceId])) {
return $this->_audienceIdMap[$audienceId];
}
$this->_logger->log(Logger::ERROR, sprintf('Audience ID "%s" is not in datafile.', $audienceId));
$this->_errorHandler->handleError(ne... | php | public function getAudience($audienceId)
{
if (isset($this->_audienceIdMap[$audienceId])) {
return $this->_audienceIdMap[$audienceId];
}
$this->_logger->log(Logger::ERROR, sprintf('Audience ID "%s" is not in datafile.', $audienceId));
$this->_errorHandler->handleError(ne... | [
"public",
"function",
"getAudience",
"(",
"$",
"audienceId",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_audienceIdMap",
"[",
"$",
"audienceId",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_audienceIdMap",
"[",
"$",
"audienceId",
"]",
... | @param $audienceId string ID of the audience.
@return Audience Entity corresponding to the ID.
Null is returned if ID is invalid. | [
"@param",
"$audienceId",
"string",
"ID",
"of",
"the",
"audience",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/ProjectConfig.php#L473-L483 |
optimizely/php-sdk | src/Optimizely/ProjectConfig.php | ProjectConfig.getAttribute | public function getAttribute($attributeKey)
{
$hasReservedPrefix = strpos($attributeKey, self::RESERVED_ATTRIBUTE_PREFIX) === 0;
if (isset($this->_attributeKeyMap[$attributeKey])) {
if ($hasReservedPrefix) {
$this->_logger->log(
Logger::WARNING,
... | php | public function getAttribute($attributeKey)
{
$hasReservedPrefix = strpos($attributeKey, self::RESERVED_ATTRIBUTE_PREFIX) === 0;
if (isset($this->_attributeKeyMap[$attributeKey])) {
if ($hasReservedPrefix) {
$this->_logger->log(
Logger::WARNING,
... | [
"public",
"function",
"getAttribute",
"(",
"$",
"attributeKey",
")",
"{",
"$",
"hasReservedPrefix",
"=",
"strpos",
"(",
"$",
"attributeKey",
",",
"self",
"::",
"RESERVED_ATTRIBUTE_PREFIX",
")",
"===",
"0",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"... | @param $attributeKey string Key of the attribute.
@return Attribute Entity corresponding to the key.
Null is returned if key is invalid. | [
"@param",
"$attributeKey",
"string",
"Key",
"of",
"the",
"attribute",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/ProjectConfig.php#L491-L514 |
optimizely/php-sdk | src/Optimizely/ProjectConfig.php | ProjectConfig.getVariationFromKey | public function getVariationFromKey($experimentKey, $variationKey)
{
if (isset($this->_variationKeyMap[$experimentKey])
&& isset($this->_variationKeyMap[$experimentKey][$variationKey])
) {
return $this->_variationKeyMap[$experimentKey][$variationKey];
}
$this... | php | public function getVariationFromKey($experimentKey, $variationKey)
{
if (isset($this->_variationKeyMap[$experimentKey])
&& isset($this->_variationKeyMap[$experimentKey][$variationKey])
) {
return $this->_variationKeyMap[$experimentKey][$variationKey];
}
$this... | [
"public",
"function",
"getVariationFromKey",
"(",
"$",
"experimentKey",
",",
"$",
"variationKey",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_variationKeyMap",
"[",
"$",
"experimentKey",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_variat... | @param $experimentKey string Key for experiment.
@param $variationKey string Key for variation.
@return Variation Entity corresponding to the provided experiment key and variation key.
Dummy entity is returned if key or ID is invalid. | [
"@param",
"$experimentKey",
"string",
"Key",
"for",
"experiment",
".",
"@param",
"$variationKey",
"string",
"Key",
"for",
"variation",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/ProjectConfig.php#L523-L541 |
optimizely/php-sdk | src/Optimizely/ProjectConfig.php | ProjectConfig.getVariationFromId | public function getVariationFromId($experimentKey, $variationId)
{
if (isset($this->_variationIdMap[$experimentKey])
&& isset($this->_variationIdMap[$experimentKey][$variationId])
) {
return $this->_variationIdMap[$experimentKey][$variationId];
}
$this->_logg... | php | public function getVariationFromId($experimentKey, $variationId)
{
if (isset($this->_variationIdMap[$experimentKey])
&& isset($this->_variationIdMap[$experimentKey][$variationId])
) {
return $this->_variationIdMap[$experimentKey][$variationId];
}
$this->_logg... | [
"public",
"function",
"getVariationFromId",
"(",
"$",
"experimentKey",
",",
"$",
"variationId",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_variationIdMap",
"[",
"$",
"experimentKey",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_variation... | @param $experimentKey string Key for experiment.
@param $variationId string ID for variation.
@return Variation Entity corresponding to the provided experiment key and variation ID.
Dummy entity is returned if key or ID is invalid. | [
"@param",
"$experimentKey",
"string",
"Key",
"for",
"experiment",
".",
"@param",
"$variationId",
"string",
"ID",
"for",
"variation",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/ProjectConfig.php#L550-L568 |
optimizely/php-sdk | src/Optimizely/ProjectConfig.php | ProjectConfig.getFeatureVariableFromKey | public function getFeatureVariableFromKey($featureFlagKey, $variableKey)
{
$featureFlag = $this->getFeatureFlagFromKey($featureFlagKey);
if ($featureFlag && !($featureFlag->getKey())) {
return null;
}
if (isset($this->_featureFlagVariableMap[$featureFlagKey])
... | php | public function getFeatureVariableFromKey($featureFlagKey, $variableKey)
{
$featureFlag = $this->getFeatureFlagFromKey($featureFlagKey);
if ($featureFlag && !($featureFlag->getKey())) {
return null;
}
if (isset($this->_featureFlagVariableMap[$featureFlagKey])
... | [
"public",
"function",
"getFeatureVariableFromKey",
"(",
"$",
"featureFlagKey",
",",
"$",
"variableKey",
")",
"{",
"$",
"featureFlag",
"=",
"$",
"this",
"->",
"getFeatureFlagFromKey",
"(",
"$",
"featureFlagKey",
")",
";",
"if",
"(",
"$",
"featureFlag",
"&&",
"!... | Gets the feature variable instance given feature flag key and variable key
@param string Feature flag key
@param string Variable key
@return FeatureVariable / null | [
"Gets",
"the",
"feature",
"variable",
"instance",
"given",
"feature",
"flag",
"key",
"and",
"variable",
"key"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/ProjectConfig.php#L578-L603 |
optimizely/php-sdk | src/Optimizely/ProjectConfig.php | ProjectConfig.getForcedVariation | 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->... | php | 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->... | [
"public",
"function",
"getForcedVariation",
"(",
"$",
"experimentKey",
",",
"$",
"userId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_forcedVariationMap",
"[",
"$",
"userId",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"lo... | Gets the forced variation key for the given user and experiment.
@param $experimentKey string Key for experiment.
@param $userId string The user Id.
@return Variation The variation which the given user and experiment should be forced into. | [
"Gets",
"the",
"forced",
"variation",
"key",
"for",
"the",
"given",
"user",
"and",
"experiment",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/ProjectConfig.php#L619-L647 |
optimizely/php-sdk | src/Optimizely/ProjectConfig.php | ProjectConfig.setForcedVariation | public function setForcedVariation($experimentKey, $userId, $variationKey)
{
// check for empty string Variation key
if (!is_null($variationKey) && !Validator::validateNonEmptyString($variationKey)) {
$this->_logger->log(Logger::ERROR, sprintf(Errors::INVALID_FORMAT, Optimizely::VARIATI... | php | public function setForcedVariation($experimentKey, $userId, $variationKey)
{
// check for empty string Variation key
if (!is_null($variationKey) && !Validator::validateNonEmptyString($variationKey)) {
$this->_logger->log(Logger::ERROR, sprintf(Errors::INVALID_FORMAT, Optimizely::VARIATI... | [
"public",
"function",
"setForcedVariation",
"(",
"$",
"experimentKey",
",",
"$",
"userId",
",",
"$",
"variationKey",
")",
"{",
"// check for empty string Variation key",
"if",
"(",
"!",
"is_null",
"(",
"$",
"variationKey",
")",
"&&",
"!",
"Validator",
"::",
"val... | Sets an associative array of user IDs to an associative array of experiments
to forced variations.
@param $experimentKey string Key for experiment.
@param $userId string The user Id.
@param $variationKey string Key for variation. If null, then clear the existing experiment-to-variation mapping.
@return boolean A bool... | [
"Sets",
"an",
"associative",
"array",
"of",
"user",
"IDs",
"to",
"an",
"associative",
"array",
"of",
"experiments",
"to",
"forced",
"variations",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/ProjectConfig.php#L659-L695 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.getBucketingId | protected function getBucketingId($userId, $userAttributes)
{
$bucketingIdKey = ControlAttributes::BUCKETING_ID;
if (isset($userAttributes[$bucketingIdKey])) {
if (is_string($userAttributes[$bucketingIdKey])) {
return $userAttributes[$bucketingIdKey];
}
... | php | protected function getBucketingId($userId, $userAttributes)
{
$bucketingIdKey = ControlAttributes::BUCKETING_ID;
if (isset($userAttributes[$bucketingIdKey])) {
if (is_string($userAttributes[$bucketingIdKey])) {
return $userAttributes[$bucketingIdKey];
}
... | [
"protected",
"function",
"getBucketingId",
"(",
"$",
"userId",
",",
"$",
"userAttributes",
")",
"{",
"$",
"bucketingIdKey",
"=",
"ControlAttributes",
"::",
"BUCKETING_ID",
";",
"if",
"(",
"isset",
"(",
"$",
"userAttributes",
"[",
"$",
"bucketingIdKey",
"]",
")... | Gets the ID for Bucketing
@param string $userId user ID
@param array $userAttributes user attributes
@return String representing bucketing ID if it is a String type in attributes else return user ID. | [
"Gets",
"the",
"ID",
"for",
"Bucketing"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L92-L103 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.getVariation | public function getVariation(Experiment $experiment, $userId, $attributes = null)
{
$bucketingId = $this->getBucketingId($userId, $attributes);
if (!$experiment->isExperimentRunning()) {
$this->_logger->log(Logger::INFO, sprintf('Experiment "%s" is not running.', $experiment->getKey()))... | php | public function getVariation(Experiment $experiment, $userId, $attributes = null)
{
$bucketingId = $this->getBucketingId($userId, $attributes);
if (!$experiment->isExperimentRunning()) {
$this->_logger->log(Logger::INFO, sprintf('Experiment "%s" is not running.', $experiment->getKey()))... | [
"public",
"function",
"getVariation",
"(",
"Experiment",
"$",
"experiment",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"bucketingId",
"=",
"$",
"this",
"->",
"getBucketingId",
"(",
"$",
"userId",
",",
"$",
"attributes",
")",
... | Determine which variation to show the user.
@param $experiment Experiment Experiment to get the variation for.
@param $userId string User identifier.
@param $attributes array Attributes of the user.
@return Variation Variation which the user is bucketed into. | [
"Determine",
"which",
"variation",
"to",
"show",
"the",
"user",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L114-L161 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.getVariationForFeature | public function getVariationForFeature(FeatureFlag $featureFlag, $userId, $userAttributes)
{
//Evaluate in this order:
//1. Attempt to bucket user into experiment using feature flag.
//2. Attempt to bucket user into rollout using the feature flag.
// Check if the feature flag is und... | php | public function getVariationForFeature(FeatureFlag $featureFlag, $userId, $userAttributes)
{
//Evaluate in this order:
//1. Attempt to bucket user into experiment using feature flag.
//2. Attempt to bucket user into rollout using the feature flag.
// Check if the feature flag is und... | [
"public",
"function",
"getVariationForFeature",
"(",
"FeatureFlag",
"$",
"featureFlag",
",",
"$",
"userId",
",",
"$",
"userAttributes",
")",
"{",
"//Evaluate in this order:",
"//1. Attempt to bucket user into experiment using feature flag.",
"//2. Attempt to bucket user into rollou... | Get the variation the user is bucketed into for the given FeatureFlag
@param FeatureFlag $featureFlag The feature flag the user wants to access
@param string $userId user ID
@param array $userAttributes user attributes
@return Decision if getVariationForFeatureExperiment or getVariationForFea... | [
"Get",
"the",
"variation",
"the",
"user",
"is",
"bucketed",
"into",
"for",
"the",
"given",
"FeatureFlag"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L172-L201 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.getVariationForFeatureExperiment | 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))... | php | 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))... | [
"public",
"function",
"getVariationForFeatureExperiment",
"(",
"FeatureFlag",
"$",
"featureFlag",
",",
"$",
"userId",
",",
"$",
"userAttributes",
")",
"{",
"$",
"featureFlagKey",
"=",
"$",
"featureFlag",
"->",
"getKey",
"(",
")",
";",
"$",
"experimentIds",
"=",
... | 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 th... | [
"Get",
"the",
"variation",
"if",
"the",
"user",
"is",
"bucketed",
"for",
"one",
"of",
"the",
"experiments",
"on",
"this",
"feature",
"flag"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L212-L251 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.getVariationForFeatureRollout | public function getVariationForFeatureRollout(FeatureFlag $featureFlag, $userId, $userAttributes)
{
$bucketing_id = $this->getBucketingId($userId, $userAttributes);
$featureFlagKey = $featureFlag->getKey();
$rollout_id = $featureFlag->getRolloutId();
if (empty($rollout_id)) {
... | php | public function getVariationForFeatureRollout(FeatureFlag $featureFlag, $userId, $userAttributes)
{
$bucketing_id = $this->getBucketingId($userId, $userAttributes);
$featureFlagKey = $featureFlag->getKey();
$rollout_id = $featureFlag->getRolloutId();
if (empty($rollout_id)) {
... | [
"public",
"function",
"getVariationForFeatureRollout",
"(",
"FeatureFlag",
"$",
"featureFlag",
",",
"$",
"userId",
",",
"$",
"userAttributes",
")",
"{",
"$",
"bucketing_id",
"=",
"$",
"this",
"->",
"getBucketingId",
"(",
"$",
"userId",
",",
"$",
"userAttributes"... | Get the variation if the user is bucketed into rollout for this feature flag
Evaluate the user for rules in priority order by seeing if the user satisfies the audience.
Fall back onto the everyone else rule if the user is ever excluded from a rule due to traffic allocation.
@param FeatureFlag $featureFlag The feat... | [
"Get",
"the",
"variation",
"if",
"the",
"user",
"is",
"bucketed",
"into",
"rollout",
"for",
"this",
"feature",
"flag",
"Evaluate",
"the",
"user",
"for",
"rules",
"in",
"priority",
"order",
"by",
"seeing",
"if",
"the",
"user",
"satisfies",
"the",
"audience",
... | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L266-L327 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.getWhitelistedVariation | private function getWhitelistedVariation(Experiment $experiment, $userId)
{
// Check if user is whitelisted for a variation.
$forcedVariations = $experiment->getForcedVariations();
if (!is_null($forcedVariations) && isset($forcedVariations[$userId])) {
$variationKey = $forcedVari... | php | private function getWhitelistedVariation(Experiment $experiment, $userId)
{
// Check if user is whitelisted for a variation.
$forcedVariations = $experiment->getForcedVariations();
if (!is_null($forcedVariations) && isset($forcedVariations[$userId])) {
$variationKey = $forcedVari... | [
"private",
"function",
"getWhitelistedVariation",
"(",
"Experiment",
"$",
"experiment",
",",
"$",
"userId",
")",
"{",
"// Check if user is whitelisted for a variation.",
"$",
"forcedVariations",
"=",
"$",
"experiment",
"->",
"getForcedVariations",
"(",
")",
";",
"if",
... | Determine variation the user has been forced into.
@param $experiment Experiment Experiment in which user is to be bucketed.
@param $userId string string
@return null|Variation Representing the variation the user is forced into. | [
"Determine",
"variation",
"the",
"user",
"has",
"been",
"forced",
"into",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L337-L355 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.getStoredUserProfile | private function getStoredUserProfile($userId)
{
if (is_null($this->_userProfileService)) {
return null;
}
try {
$userProfileMap = $this->_userProfileService->lookup($userId);
if (is_null($userProfileMap)) {
$this->_logger->log(
... | php | private function getStoredUserProfile($userId)
{
if (is_null($this->_userProfileService)) {
return null;
}
try {
$userProfileMap = $this->_userProfileService->lookup($userId);
if (is_null($userProfileMap)) {
$this->_logger->log(
... | [
"private",
"function",
"getStoredUserProfile",
"(",
"$",
"userId",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_userProfileService",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"$",
"userProfileMap",
"=",
"$",
"this",
"->",
"_user... | Get the stored user profile for the given user ID.
@param $userId string the ID of the user.
@return null|UserProfile the stored user profile. | [
"Get",
"the",
"stored",
"user",
"profile",
"for",
"the",
"given",
"user",
"ID",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L364-L393 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.getStoredVariation | private function getStoredVariation(Experiment $experiment, UserProfile $userProfile)
{
$experimentKey = $experiment->getKey();
$userId = $userProfile->getUserId();
$variationId = $userProfile->getVariationForExperiment($experiment->getId());
if (is_null($variationId)) {
... | php | private function getStoredVariation(Experiment $experiment, UserProfile $userProfile)
{
$experimentKey = $experiment->getKey();
$userId = $userProfile->getUserId();
$variationId = $userProfile->getVariationForExperiment($experiment->getId());
if (is_null($variationId)) {
... | [
"private",
"function",
"getStoredVariation",
"(",
"Experiment",
"$",
"experiment",
",",
"UserProfile",
"$",
"userProfile",
")",
"{",
"$",
"experimentKey",
"=",
"$",
"experiment",
"->",
"getKey",
"(",
")",
";",
"$",
"userId",
"=",
"$",
"userProfile",
"->",
"g... | 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... | [
"Get",
"the",
"stored",
"variation",
"for",
"the",
"given",
"experiment",
"from",
"the",
"user",
"profile",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L403-L441 |
optimizely/php-sdk | src/Optimizely/DecisionService/DecisionService.php | DecisionService.saveVariation | private function saveVariation(Experiment $experiment, Variation $variation, UserProfile $userProfile)
{
if (is_null($this->_userProfileService)) {
return;
}
$experimentId = $experiment->getId();
$decision = $userProfile->getDecisionForExperiment($experimentId);
... | php | private function saveVariation(Experiment $experiment, Variation $variation, UserProfile $userProfile)
{
if (is_null($this->_userProfileService)) {
return;
}
$experimentId = $experiment->getId();
$decision = $userProfile->getDecisionForExperiment($experimentId);
... | [
"private",
"function",
"saveVariation",
"(",
"Experiment",
"$",
"experiment",
",",
"Variation",
"$",
"variation",
",",
"UserProfile",
"$",
"userProfile",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_userProfileService",
")",
")",
"{",
"return",
... | Save the given variation assignment to the given user profile.
@param $experiment Experiment Experiment for which we are storing the variation.
@param $variation Variation Variation the user is bucketed into.
@param $userProfile UserProfile User profile object to which we are persisting the variation assignment. | [
"Save",
"the",
"given",
"variation",
"assignment",
"to",
"the",
"given",
"user",
"profile",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/DecisionService/DecisionService.php#L450-L490 |
optimizely/php-sdk | src/Optimizely/Entity/Experiment.php | Experiment.isUserInForcedVariation | public function isUserInForcedVariation($userId)
{
$forcedVariations = $this->getForcedVariations();
return !is_null($forcedVariations) && isset($forcedVariations[$userId]);
} | php | public function isUserInForcedVariation($userId)
{
$forcedVariations = $this->getForcedVariations();
return !is_null($forcedVariations) && isset($forcedVariations[$userId]);
} | [
"public",
"function",
"isUserInForcedVariation",
"(",
"$",
"userId",
")",
"{",
"$",
"forcedVariations",
"=",
"$",
"this",
"->",
"getForcedVariations",
"(",
")",
";",
"return",
"!",
"is_null",
"(",
"$",
"forcedVariations",
")",
"&&",
"isset",
"(",
"$",
"force... | Determine if user is in forced variation of experiment.
@param $userId string ID of the user.
@return boolean True if user is in forced variation of experiment. False otherwise. | [
"Determine",
"if",
"user",
"is",
"in",
"forced",
"variation",
"of",
"experiment",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Entity/Experiment.php#L319-L323 |
optimizely/php-sdk | src/Optimizely/Utils/GeneratorUtils.php | GeneratorUtils.getRandomUuid | public static function getRandomUuid()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for ... | php | public static function getRandomUuid()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for ... | [
"public",
"static",
"function",
"getRandomUuid",
"(",
")",
"{",
"return",
"sprintf",
"(",
"'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'",
",",
"// 32 bits for \"time_low\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"/... | Generate random uuid
@return string - version 4 uuid | [
"Generate",
"random",
"uuid"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/GeneratorUtils.php#L27-L48 |
optimizely/php-sdk | src/Optimizely/UserProfile/UserProfileUtils.php | UserProfileUtils.isValidUserProfileMap | public static function isValidUserProfileMap($userProfileMap)
{
if (!is_array($userProfileMap)) {
return false;
}
if (!isset($userProfileMap[self::USER_ID_KEY])) {
return false;
}
if (!isset($userProfileMap[self::EXPERIMENT_BUCKET_MAP_KEY])) {
... | php | public static function isValidUserProfileMap($userProfileMap)
{
if (!is_array($userProfileMap)) {
return false;
}
if (!isset($userProfileMap[self::USER_ID_KEY])) {
return false;
}
if (!isset($userProfileMap[self::EXPERIMENT_BUCKET_MAP_KEY])) {
... | [
"public",
"static",
"function",
"isValidUserProfileMap",
"(",
"$",
"userProfileMap",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"userProfileMap",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"userProfileMap",
"[",
"... | Grab the revenue value from the event tags. "revenue" is a reserved keyword.
@param $userProfileMap array Representing the user profile.
@return true if the given user profile map is valid, false otherwise. | [
"Grab",
"the",
"revenue",
"value",
"from",
"the",
"event",
"tags",
".",
"revenue",
"is",
"a",
"reserved",
"keyword",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/UserProfile/UserProfileUtils.php#L34-L67 |
optimizely/php-sdk | src/Optimizely/UserProfile/UserProfileUtils.php | UserProfileUtils.convertMapToUserProfile | public static function convertMapToUserProfile($userProfileMap)
{
$userId = $userProfileMap[self::USER_ID_KEY];
$experimentBucketMap = array();
foreach ($userProfileMap[self::EXPERIMENT_BUCKET_MAP_KEY] as $experimentId => $decisionMap) {
$variationId = $decisionMap[self::VARIATIO... | php | public static function convertMapToUserProfile($userProfileMap)
{
$userId = $userProfileMap[self::USER_ID_KEY];
$experimentBucketMap = array();
foreach ($userProfileMap[self::EXPERIMENT_BUCKET_MAP_KEY] as $experimentId => $decisionMap) {
$variationId = $decisionMap[self::VARIATIO... | [
"public",
"static",
"function",
"convertMapToUserProfile",
"(",
"$",
"userProfileMap",
")",
"{",
"$",
"userId",
"=",
"$",
"userProfileMap",
"[",
"self",
"::",
"USER_ID_KEY",
"]",
";",
"$",
"experimentBucketMap",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"... | Convert the given user profile map into a UserProfile object.
@param $userProfileMap array
@return UserProfile The user profile object constructed from the given map. | [
"Convert",
"the",
"given",
"user",
"profile",
"map",
"into",
"a",
"UserProfile",
"object",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/UserProfile/UserProfileUtils.php#L76-L86 |
optimizely/php-sdk | src/Optimizely/UserProfile/UserProfileUtils.php | UserProfileUtils.convertUserProfileToMap | public static function convertUserProfileToMap($userProfile)
{
$userProfileMap = array(
self::USER_ID_KEY => $userProfile->getUserId(),
self::EXPERIMENT_BUCKET_MAP_KEY => array()
);
$experimentBucketMap = $userProfile->getExperimentBucketMap();
foreach ($exper... | php | public static function convertUserProfileToMap($userProfile)
{
$userProfileMap = array(
self::USER_ID_KEY => $userProfile->getUserId(),
self::EXPERIMENT_BUCKET_MAP_KEY => array()
);
$experimentBucketMap = $userProfile->getExperimentBucketMap();
foreach ($exper... | [
"public",
"static",
"function",
"convertUserProfileToMap",
"(",
"$",
"userProfile",
")",
"{",
"$",
"userProfileMap",
"=",
"array",
"(",
"self",
"::",
"USER_ID_KEY",
"=>",
"$",
"userProfile",
"->",
"getUserId",
"(",
")",
",",
"self",
"::",
"EXPERIMENT_BUCKET_MAP_... | Convert the given UserProfile object into a map.
@param $userProfile UserProfile The user profile object to convert to a map.
@return array The map representing the user profile object. | [
"Convert",
"the",
"given",
"UserProfile",
"object",
"into",
"a",
"map",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/UserProfile/UserProfileUtils.php#L95-L108 |
optimizely/php-sdk | src/Optimizely/Utils/ConfigParser.php | ConfigParser.generateMap | public static function generateMap($entities, $entityId, $entityClass)
{
$entityMap = [];
foreach ($entities as $entity) {
if ($entity instanceof $entityClass) {
$entityObject = $entity;
} else {
$entityObject = new $entityClass;
... | php | public static function generateMap($entities, $entityId, $entityClass)
{
$entityMap = [];
foreach ($entities as $entity) {
if ($entity instanceof $entityClass) {
$entityObject = $entity;
} else {
$entityObject = new $entityClass;
... | [
"public",
"static",
"function",
"generateMap",
"(",
"$",
"entities",
",",
"$",
"entityId",
",",
"$",
"entityClass",
")",
"{",
"$",
"entityMap",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"entit... | @param $entities array Entities to be stored as objects.
@param $entityId string ID to be used in generating map.
@param $entityClass string Class of entities.
@return array Map mapping entity identifier to the entity. | [
"@param",
"$entities",
"array",
"Entities",
"to",
"be",
"stored",
"as",
"objects",
".",
"@param",
"$entityId",
"string",
"ID",
"to",
"be",
"used",
"in",
"generating",
"map",
".",
"@param",
"$entityClass",
"string",
"Class",
"of",
"entities",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/ConfigParser.php#L29-L54 |
optimizely/php-sdk | src/Optimizely/Notification/NotificationCenter.php | NotificationCenter.addNotificationListener | public function addNotificationListener($notification_type, $notification_callback)
{
if (!NotificationType::isNotificationTypeValid($notification_type)) {
$this->_logger->log(Logger::ERROR, "Invalid notification type.");
$this->_errorHandler->handleError(new InvalidNotificationTypeE... | php | public function addNotificationListener($notification_type, $notification_callback)
{
if (!NotificationType::isNotificationTypeValid($notification_type)) {
$this->_logger->log(Logger::ERROR, "Invalid notification type.");
$this->_errorHandler->handleError(new InvalidNotificationTypeE... | [
"public",
"function",
"addNotificationListener",
"(",
"$",
"notification_type",
",",
"$",
"notification_callback",
")",
"{",
"if",
"(",
"!",
"NotificationType",
"::",
"isNotificationTypeValid",
"(",
"$",
"notification_type",
")",
")",
"{",
"$",
"this",
"->",
"_log... | Adds a notification callback for a notification type to the notification center
@param string $notification_type One of the constants defined in NotificationType
@param callable $notification_callback A valid PHP callback
@return null Given invalid notification type/callback
-1 Given callback has been alrea... | [
"Adds",
"a",
"notification",
"callback",
"for",
"a",
"notification",
"type",
"to",
"the",
"notification",
"center"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Notification/NotificationCenter.php#L68-L94 |
optimizely/php-sdk | src/Optimizely/Notification/NotificationCenter.php | NotificationCenter.removeNotificationListener | public function removeNotificationListener($notification_id)
{
foreach ($this->_notifications as $notification_type => $notifications) {
foreach (array_keys($notifications) as $id) {
if ($notification_id == $id) {
unset($this->_notifications[$notification_type... | php | public function removeNotificationListener($notification_id)
{
foreach ($this->_notifications as $notification_type => $notifications) {
foreach (array_keys($notifications) as $id) {
if ($notification_id == $id) {
unset($this->_notifications[$notification_type... | [
"public",
"function",
"removeNotificationListener",
"(",
"$",
"notification_id",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_notifications",
"as",
"$",
"notification_type",
"=>",
"$",
"notifications",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"notific... | Removes notification callback from the notification center
@param int $notification_id notification ID
@return true When callback removed
false When no callback found for the given notification ID | [
"Removes",
"notification",
"callback",
"from",
"the",
"notification",
"center"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Notification/NotificationCenter.php#L104-L118 |
optimizely/php-sdk | src/Optimizely/Notification/NotificationCenter.php | NotificationCenter.clearNotifications | public function clearNotifications($notification_type)
{
$this->_logger->log(
Logger::WARNING,
"'clearNotifications' is deprecated. Call 'clearNotificationListeners' instead."
);
$this->clearNotificationListeners($notification_type);
} | php | public function clearNotifications($notification_type)
{
$this->_logger->log(
Logger::WARNING,
"'clearNotifications' is deprecated. Call 'clearNotificationListeners' instead."
);
$this->clearNotificationListeners($notification_type);
} | [
"public",
"function",
"clearNotifications",
"(",
"$",
"notification_type",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"log",
"(",
"Logger",
"::",
"WARNING",
",",
"\"'clearNotifications' is deprecated. Call 'clearNotificationListeners' instead.\"",
")",
";",
"$",
"thi... | Logs deprecation message
@deprecated Use 'clearNotificationListeners' instead. | [
"Logs",
"deprecation",
"message"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Notification/NotificationCenter.php#L125-L132 |
optimizely/php-sdk | src/Optimizely/Notification/NotificationCenter.php | NotificationCenter.clearNotificationListeners | public function clearNotificationListeners($notification_type)
{
if (!NotificationType::isNotificationTypeValid($notification_type)) {
$this->_logger->log(Logger::ERROR, "Invalid notification type.");
$this->_errorHandler->handleError(new InvalidNotificationTypeException('Invalid not... | php | public function clearNotificationListeners($notification_type)
{
if (!NotificationType::isNotificationTypeValid($notification_type)) {
$this->_logger->log(Logger::ERROR, "Invalid notification type.");
$this->_errorHandler->handleError(new InvalidNotificationTypeException('Invalid not... | [
"public",
"function",
"clearNotificationListeners",
"(",
"$",
"notification_type",
")",
"{",
"if",
"(",
"!",
"NotificationType",
"::",
"isNotificationTypeValid",
"(",
"$",
"notification_type",
")",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"log",
"(",
"Logge... | Removes all notification callbacks for the given notification type
@param string $notification_type One of the constants defined in NotificationType | [
"Removes",
"all",
"notification",
"callbacks",
"for",
"the",
"given",
"notification",
"type"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Notification/NotificationCenter.php#L139-L149 |
optimizely/php-sdk | src/Optimizely/Notification/NotificationCenter.php | NotificationCenter.sendNotifications | public function sendNotifications($notification_type, array $args = [])
{
if (!isset($this->_notifications[$notification_type])) {
// No exception thrown and error logged since this method will be called from
// within the SDK
return;
}
/**
* Not... | php | public function sendNotifications($notification_type, array $args = [])
{
if (!isset($this->_notifications[$notification_type])) {
// No exception thrown and error logged since this method will be called from
// within the SDK
return;
}
/**
* Not... | [
"public",
"function",
"sendNotifications",
"(",
"$",
"notification_type",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_notifications",
"[",
"$",
"notification_type",
"]",
")",
")",
"{",
"// No exc... | Executes all registered callbacks for the given notification type
@param string $notification_type One of the constants defined in NotificationType
@param array $args Array of items to pass as arguments to the callback | [
"Executes",
"all",
"registered",
"callbacks",
"for",
"the",
"given",
"notification",
"type"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Notification/NotificationCenter.php#L182-L212 |
optimizely/php-sdk | src/Optimizely/Notification/NotificationCenter.php | NotificationCenter.reportArgumentCountError | public function reportArgumentCountError()
{
$this->_logger->log(Logger::ERROR, "Problem calling notify callback.");
$this->_errorHandler->handleError(
new InvalidCallbackArgumentCountException('Registered callback expects more number of arguments than the actual number')
);
... | php | public function reportArgumentCountError()
{
$this->_logger->log(Logger::ERROR, "Problem calling notify callback.");
$this->_errorHandler->handleError(
new InvalidCallbackArgumentCountException('Registered callback expects more number of arguments than the actual number')
);
... | [
"public",
"function",
"reportArgumentCountError",
"(",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"log",
"(",
"Logger",
"::",
"ERROR",
",",
"\"Problem calling notify callback.\"",
")",
";",
"$",
"this",
"->",
"_errorHandler",
"->",
"handleError",
"(",
"new",
... | Logs and raises an exception when registered callback expects more number of arguments when executed | [
"Logs",
"and",
"raises",
"an",
"exception",
"when",
"registered",
"callback",
"expects",
"more",
"number",
"of",
"arguments",
"when",
"executed"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Notification/NotificationCenter.php#L217-L223 |
optimizely/php-sdk | src/Optimizely/Utils/EventTagUtils.php | EventTagUtils.getRevenueValue | public static function getRevenueValue($eventTags, $logger)
{
if (!$eventTags) {
$logger->log(Logger::DEBUG, "Event tags is undefined.");
return null;
}
if (!is_array($eventTags)) {
$logger->log(Logger::DEBUG, "Event tags is not a dictionary.");
... | php | public static function getRevenueValue($eventTags, $logger)
{
if (!$eventTags) {
$logger->log(Logger::DEBUG, "Event tags is undefined.");
return null;
}
if (!is_array($eventTags)) {
$logger->log(Logger::DEBUG, "Event tags is not a dictionary.");
... | [
"public",
"static",
"function",
"getRevenueValue",
"(",
"$",
"eventTags",
",",
"$",
"logger",
")",
"{",
"if",
"(",
"!",
"$",
"eventTags",
")",
"{",
"$",
"logger",
"->",
"log",
"(",
"Logger",
"::",
"DEBUG",
",",
"\"Event tags is undefined.\"",
")",
";",
"... | Grab the revenue value from the event tags. "revenue" is a reserved keyword.
The value will be parsed to an integer if possible.
Example:
4.0 or "4.0" will be parsed to int(4).
4.1 will not be parsed and the method will return null.
@param $eventTags array Representing metadata associated with the event.
@return inte... | [
"Grab",
"the",
"revenue",
"value",
"from",
"the",
"event",
"tags",
".",
"revenue",
"is",
"a",
"reserved",
"keyword",
".",
"The",
"value",
"will",
"be",
"parsed",
"to",
"an",
"integer",
"if",
"possible",
".",
"Example",
":",
"4",
".",
"0",
"or",
"4",
... | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/EventTagUtils.php#L43-L74 |
optimizely/php-sdk | src/Optimizely/Utils/EventTagUtils.php | EventTagUtils.getNumericValue | public static function getNumericValue($eventTags, $logger)
{
if (!$eventTags) {
$logger->log(Logger::DEBUG, "Event tags is undefined.");
return null;
}
if (!is_array($eventTags)) {
$logger->log(Logger::DEBUG, "Event tags is not a dictionary.");
... | php | public static function getNumericValue($eventTags, $logger)
{
if (!$eventTags) {
$logger->log(Logger::DEBUG, "Event tags is undefined.");
return null;
}
if (!is_array($eventTags)) {
$logger->log(Logger::DEBUG, "Event tags is not a dictionary.");
... | [
"public",
"static",
"function",
"getNumericValue",
"(",
"$",
"eventTags",
",",
"$",
"logger",
")",
"{",
"if",
"(",
"!",
"$",
"eventTags",
")",
"{",
"$",
"logger",
"->",
"log",
"(",
"Logger",
"::",
"DEBUG",
",",
"\"Event tags is undefined.\"",
")",
";",
"... | Grab the numeric event value from the event tags. "value" is a reserved keyword.
The value of 'value' can be a float or a numeric string
@param $eventTags array Representing metadata associated with the event.
@param $logger instance of LoggerInterface
@return float value of 'value' or null | [
"Grab",
"the",
"numeric",
"event",
"value",
"from",
"the",
"event",
"tags",
".",
"value",
"is",
"a",
"reserved",
"keyword",
".",
"The",
"value",
"of",
"value",
"can",
"be",
"a",
"float",
"or",
"a",
"numeric",
"string"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/EventTagUtils.php#L85-L117 |
optimizely/php-sdk | src/Optimizely/Utils/CustomAttributeConditionEvaluator.php | CustomAttributeConditionEvaluator.setNullForMissingKeys | protected function setNullForMissingKeys(array $leafCondition)
{
$keys = ['type', 'match', 'value'];
foreach ($keys as $key) {
$leafCondition[$key] = isset($leafCondition[$key]) ? $leafCondition[$key]: null;
}
return $leafCondition;
} | php | protected function setNullForMissingKeys(array $leafCondition)
{
$keys = ['type', 'match', 'value'];
foreach ($keys as $key) {
$leafCondition[$key] = isset($leafCondition[$key]) ? $leafCondition[$key]: null;
}
return $leafCondition;
} | [
"protected",
"function",
"setNullForMissingKeys",
"(",
"array",
"$",
"leafCondition",
")",
"{",
"$",
"keys",
"=",
"[",
"'type'",
",",
"'match'",
",",
"'value'",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"leafCondition",
"[",... | Sets null for missing keys in a leaf condition.
@param array $leafCondition The leaf condition node of an audience. | [
"Sets",
"null",
"for",
"missing",
"keys",
"in",
"a",
"leaf",
"condition",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/CustomAttributeConditionEvaluator.php#L56-L64 |
optimizely/php-sdk | src/Optimizely/Utils/CustomAttributeConditionEvaluator.php | CustomAttributeConditionEvaluator.getMatchTypes | protected function getMatchTypes()
{
return array(self::EXACT_MATCH_TYPE, self::EXISTS_MATCH_TYPE, self::GREATER_THAN_MATCH_TYPE,
self::LESS_THAN_MATCH_TYPE, self::SUBSTRING_MATCH_TYPE);
} | php | protected function getMatchTypes()
{
return array(self::EXACT_MATCH_TYPE, self::EXISTS_MATCH_TYPE, self::GREATER_THAN_MATCH_TYPE,
self::LESS_THAN_MATCH_TYPE, self::SUBSTRING_MATCH_TYPE);
} | [
"protected",
"function",
"getMatchTypes",
"(",
")",
"{",
"return",
"array",
"(",
"self",
"::",
"EXACT_MATCH_TYPE",
",",
"self",
"::",
"EXISTS_MATCH_TYPE",
",",
"self",
"::",
"GREATER_THAN_MATCH_TYPE",
",",
"self",
"::",
"LESS_THAN_MATCH_TYPE",
",",
"self",
"::",
... | Gets the supported match types for condition evaluation.
@return array List of supported match types. | [
"Gets",
"the",
"supported",
"match",
"types",
"for",
"condition",
"evaluation",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/CustomAttributeConditionEvaluator.php#L71-L75 |
optimizely/php-sdk | src/Optimizely/Utils/CustomAttributeConditionEvaluator.php | CustomAttributeConditionEvaluator.getEvaluatorByMatchType | protected function getEvaluatorByMatchType($matchType)
{
$evaluatorsByMatchType = array();
$evaluatorsByMatchType[self::EXACT_MATCH_TYPE] = 'exactEvaluator';
$evaluatorsByMatchType[self::EXISTS_MATCH_TYPE] = 'existsEvaluator';
$evaluatorsByMatchType[self::GREATER_THAN_MATCH_TYPE] = '... | php | protected function getEvaluatorByMatchType($matchType)
{
$evaluatorsByMatchType = array();
$evaluatorsByMatchType[self::EXACT_MATCH_TYPE] = 'exactEvaluator';
$evaluatorsByMatchType[self::EXISTS_MATCH_TYPE] = 'existsEvaluator';
$evaluatorsByMatchType[self::GREATER_THAN_MATCH_TYPE] = '... | [
"protected",
"function",
"getEvaluatorByMatchType",
"(",
"$",
"matchType",
")",
"{",
"$",
"evaluatorsByMatchType",
"=",
"array",
"(",
")",
";",
"$",
"evaluatorsByMatchType",
"[",
"self",
"::",
"EXACT_MATCH_TYPE",
"]",
"=",
"'exactEvaluator'",
";",
"$",
"evaluators... | Gets the evaluator method name for the given match type.
@param string $matchType Match type for which to get evaluator.
@return string Corresponding evaluator method name. | [
"Gets",
"the",
"evaluator",
"method",
"name",
"for",
"the",
"given",
"match",
"type",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/CustomAttributeConditionEvaluator.php#L84-L94 |
optimizely/php-sdk | src/Optimizely/Utils/CustomAttributeConditionEvaluator.php | CustomAttributeConditionEvaluator.isValueTypeValidForExactConditions | protected function isValueTypeValidForExactConditions($value)
{
if (is_string($value) || is_bool($value) || is_int($value) || is_float($value)) {
return true;
}
return false;
} | php | protected function isValueTypeValidForExactConditions($value)
{
if (is_string($value) || is_bool($value) || is_int($value) || is_float($value)) {
return true;
}
return false;
} | [
"protected",
"function",
"isValueTypeValidForExactConditions",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"||",
"is_bool",
"(",
"$",
"value",
")",
"||",
"is_int",
"(",
"$",
"value",
")",
"||",
"is_float",
"(",
"$",
"valu... | Checks if the given input is a valid value for exact condition evaluation.
@param $value Input to check.
@return boolean true if given input is a string/boolean/number, false otherwise. | [
"Checks",
"if",
"the",
"given",
"input",
"is",
"a",
"valid",
"value",
"for",
"exact",
"condition",
"evaluation",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/CustomAttributeConditionEvaluator.php#L103-L110 |
optimizely/php-sdk | src/Optimizely/Utils/CustomAttributeConditionEvaluator.php | CustomAttributeConditionEvaluator.exactEvaluator | protected function exactEvaluator($condition)
{
$conditionName = $condition['name'];
$conditionValue = $condition['value'];
$userValue = isset($this->userAttributes[$conditionName]) ? $this->userAttributes[$conditionName]: null;
if (!$this->isValueTypeValidForExactConditions($condit... | php | protected function exactEvaluator($condition)
{
$conditionName = $condition['name'];
$conditionValue = $condition['value'];
$userValue = isset($this->userAttributes[$conditionName]) ? $this->userAttributes[$conditionName]: null;
if (!$this->isValueTypeValidForExactConditions($condit... | [
"protected",
"function",
"exactEvaluator",
"(",
"$",
"condition",
")",
"{",
"$",
"conditionName",
"=",
"$",
"condition",
"[",
"'name'",
"]",
";",
"$",
"conditionValue",
"=",
"$",
"condition",
"[",
"'value'",
"]",
";",
"$",
"userValue",
"=",
"isset",
"(",
... | Evaluate the given exact match condition for the given user attributes.
@param object $condition
@return null|boolean true if the user attribute value is equal (===) to the condition value,
false if the user attribute value is not equal (!==) to the condition value,
null if the condition value or user attribute valu... | [
"Evaluate",
"the",
"given",
"exact",
"match",
"condition",
"for",
"the",
"given",
"user",
"attributes",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/CustomAttributeConditionEvaluator.php#L123-L160 |
optimizely/php-sdk | src/Optimizely/Utils/CustomAttributeConditionEvaluator.php | CustomAttributeConditionEvaluator.substringEvaluator | protected function substringEvaluator($condition)
{
$conditionName = $condition['name'];
$conditionValue = $condition['value'];
$userValue = isset($this->userAttributes[$conditionName]) ? $this->userAttributes[$conditionName]: null;
if (!is_string($conditionValue)) {
$th... | php | protected function substringEvaluator($condition)
{
$conditionName = $condition['name'];
$conditionValue = $condition['value'];
$userValue = isset($this->userAttributes[$conditionName]) ? $this->userAttributes[$conditionName]: null;
if (!is_string($conditionValue)) {
$th... | [
"protected",
"function",
"substringEvaluator",
"(",
"$",
"condition",
")",
"{",
"$",
"conditionName",
"=",
"$",
"condition",
"[",
"'name'",
"]",
";",
"$",
"conditionValue",
"=",
"$",
"condition",
"[",
"'value'",
"]",
";",
"$",
"userValue",
"=",
"isset",
"(... | Evaluate the given substring than match condition for the given user attributes.
@param object $condition
@return boolean true if the condition value is a substring of the user attribute value,
false if the condition value is not a substring of the user attribute value,
null if the condition value isn't a string or ... | [
"Evaluate",
"the",
"given",
"substring",
"than",
"match",
"condition",
"for",
"the",
"given",
"user",
"attributes",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/CustomAttributeConditionEvaluator.php#L280-L305 |
optimizely/php-sdk | src/Optimizely/Utils/CustomAttributeConditionEvaluator.php | CustomAttributeConditionEvaluator.evaluate | public function evaluate($leafCondition)
{
$leafCondition = $this->setNullForMissingKeys($leafCondition);
if ($leafCondition['type'] !== self::CUSTOM_ATTRIBUTE_CONDITION_TYPE) {
$this->logger->log(Logger::WARNING, sprintf(
logs::UNKNOWN_CONDITION_TYPE,
js... | php | public function evaluate($leafCondition)
{
$leafCondition = $this->setNullForMissingKeys($leafCondition);
if ($leafCondition['type'] !== self::CUSTOM_ATTRIBUTE_CONDITION_TYPE) {
$this->logger->log(Logger::WARNING, sprintf(
logs::UNKNOWN_CONDITION_TYPE,
js... | [
"public",
"function",
"evaluate",
"(",
"$",
"leafCondition",
")",
"{",
"$",
"leafCondition",
"=",
"$",
"this",
"->",
"setNullForMissingKeys",
"(",
"$",
"leafCondition",
")",
";",
"if",
"(",
"$",
"leafCondition",
"[",
"'type'",
"]",
"!==",
"self",
"::",
"CU... | Function to evaluate audience conditions against user's attributes.
@param array $leafCondition Condition to be evaluated.
@return null|boolean true/false if the given user attributes match/don't match the given conditions,
null if the given user attributes and conditions can't be evaluated. | [
"Function",
"to",
"evaluate",
"audience",
"conditions",
"against",
"user",
"s",
"attributes",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/CustomAttributeConditionEvaluator.php#L315-L365 |
optimizely/php-sdk | src/Optimizely/Utils/ConditionTreeEvaluator.php | ConditionTreeEvaluator.getEvaluatorByOperatorType | protected function getEvaluatorByOperatorType($operator)
{
$evaluatorsByOperator = array();
$evaluatorsByOperator[self::AND_OPERATOR] = 'andEvaluator';
$evaluatorsByOperator[self::OR_OPERATOR] = 'orEvaluator';
$evaluatorsByOperator[self::NOT_OPERATOR] = 'notEvaluator';
retur... | php | protected function getEvaluatorByOperatorType($operator)
{
$evaluatorsByOperator = array();
$evaluatorsByOperator[self::AND_OPERATOR] = 'andEvaluator';
$evaluatorsByOperator[self::OR_OPERATOR] = 'orEvaluator';
$evaluatorsByOperator[self::NOT_OPERATOR] = 'notEvaluator';
retur... | [
"protected",
"function",
"getEvaluatorByOperatorType",
"(",
"$",
"operator",
")",
"{",
"$",
"evaluatorsByOperator",
"=",
"array",
"(",
")",
";",
"$",
"evaluatorsByOperator",
"[",
"self",
"::",
"AND_OPERATOR",
"]",
"=",
"'andEvaluator'",
";",
"$",
"evaluatorsByOper... | Returns corresponding evaluator method name for the given operator.
@param mixed $operator Operator to get relevant evaluator method.
@return string Corresponding method to the given operator. | [
"Returns",
"corresponding",
"evaluator",
"method",
"name",
"for",
"the",
"given",
"operator",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/ConditionTreeEvaluator.php#L43-L51 |
optimizely/php-sdk | src/Optimizely/Utils/ConditionTreeEvaluator.php | ConditionTreeEvaluator.andEvaluator | protected function andEvaluator(array $conditions, callable $leafEvaluator)
{
$sawNullResult = false;
foreach ($conditions as $condition) {
$result = $this->evaluate($condition, $leafEvaluator);
if ($result === false) {
return false;
}... | php | protected function andEvaluator(array $conditions, callable $leafEvaluator)
{
$sawNullResult = false;
foreach ($conditions as $condition) {
$result = $this->evaluate($condition, $leafEvaluator);
if ($result === false) {
return false;
}... | [
"protected",
"function",
"andEvaluator",
"(",
"array",
"$",
"conditions",
",",
"callable",
"$",
"leafEvaluator",
")",
"{",
"$",
"sawNullResult",
"=",
"false",
";",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"condition",
")",
"{",
"$",
"result",
"=",
"$"... | Evaluates an array of conditions as if the evaluator had been applied
to each entry and the results AND-ed together.
@param array $conditions Audience conditions list.
@param callable $leafEvaluator Method to evaluate leaf condition.
@return null|boolean True if all the operands evaluate to true.
False if a sin... | [
"Evaluates",
"an",
"array",
"of",
"conditions",
"as",
"if",
"the",
"evaluator",
"had",
"been",
"applied",
"to",
"each",
"entry",
"and",
"the",
"results",
"AND",
"-",
"ed",
"together",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/ConditionTreeEvaluator.php#L64-L80 |
optimizely/php-sdk | src/Optimizely/Utils/ConditionTreeEvaluator.php | ConditionTreeEvaluator.notEvaluator | protected function notEvaluator(array $condition, callable $leafEvaluator)
{
if (empty($condition)) {
return null;
}
$result = $this->evaluate($condition[0], $leafEvaluator);
return $result === null ? null: !$result;
} | php | protected function notEvaluator(array $condition, callable $leafEvaluator)
{
if (empty($condition)) {
return null;
}
$result = $this->evaluate($condition[0], $leafEvaluator);
return $result === null ? null: !$result;
} | [
"protected",
"function",
"notEvaluator",
"(",
"array",
"$",
"condition",
",",
"callable",
"$",
"leafEvaluator",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"condition",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"eval... | Evaluates an array of conditions as if the evaluator had been applied
to a single entry and NOT was applied to the result.
@param array $conditions Audience conditions list.
@param callable $leafEvaluator Method to evaluate leaf condition.
@return null|boolean True if the operand evaluates to false.
False if th... | [
"Evaluates",
"an",
"array",
"of",
"conditions",
"as",
"if",
"the",
"evaluator",
"had",
"been",
"applied",
"to",
"a",
"single",
"entry",
"and",
"NOT",
"was",
"applied",
"to",
"the",
"result",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/ConditionTreeEvaluator.php#L122-L130 |
optimizely/php-sdk | src/Optimizely/Utils/ConditionTreeEvaluator.php | ConditionTreeEvaluator.evaluate | public function evaluate($conditions, callable $leafEvaluator)
{
// When parsing audiences tree the leaf node is a string representing an audience ID.
// When parsing conditions of a single audience the leaf node is an associative array with all keys of type string.
if (is_string($conditions... | php | public function evaluate($conditions, callable $leafEvaluator)
{
// When parsing audiences tree the leaf node is a string representing an audience ID.
// When parsing conditions of a single audience the leaf node is an associative array with all keys of type string.
if (is_string($conditions... | [
"public",
"function",
"evaluate",
"(",
"$",
"conditions",
",",
"callable",
"$",
"leafEvaluator",
")",
"{",
"// When parsing audiences tree the leaf node is a string representing an audience ID.",
"// When parsing conditions of a single audience the leaf node is an associative array with al... | Function to evaluate audience conditions against user's attributes.
@param array $conditions Nested array of and/or/not conditions representing the audience conditions.
@param callable $leafEvaluator Method to evaluate leaf condition.
@return null|boolean Result of evaluating the conditions using the operator r... | [
"Function",
"to",
"evaluate",
"audience",
"conditions",
"against",
"user",
"s",
"attributes",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Utils/ConditionTreeEvaluator.php#L141-L158 |
optimizely/php-sdk | src/Optimizely/Bucketer.php | Bucketer.generateBucketValue | protected function generateBucketValue($bucketingKey)
{
$hashCode = $this->generateHashCode($bucketingKey);
$ratio = $hashCode / Bucketer::$MAX_HASH_VALUE;
$bucketVal = intval(floor($ratio * Bucketer::$MAX_TRAFFIC_VALUE));
/* murmurhash3_int returns both positive and negative intege... | php | protected function generateBucketValue($bucketingKey)
{
$hashCode = $this->generateHashCode($bucketingKey);
$ratio = $hashCode / Bucketer::$MAX_HASH_VALUE;
$bucketVal = intval(floor($ratio * Bucketer::$MAX_TRAFFIC_VALUE));
/* murmurhash3_int returns both positive and negative intege... | [
"protected",
"function",
"generateBucketValue",
"(",
"$",
"bucketingKey",
")",
"{",
"$",
"hashCode",
"=",
"$",
"this",
"->",
"generateHashCode",
"(",
"$",
"bucketingKey",
")",
";",
"$",
"ratio",
"=",
"$",
"hashCode",
"/",
"Bucketer",
"::",
"$",
"MAX_HASH_VAL... | Generate an integer to be used in bucketing user to a particular variation.
@param $bucketingKey string Value used for the key of the murmur hash.
@return integer Value in the closed range [0, 9999] denoting the bucket the user belongs to. | [
"Generate",
"an",
"integer",
"to",
"be",
"used",
"in",
"bucketing",
"user",
"to",
"a",
"particular",
"variation",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Bucketer.php#L85-L104 |
optimizely/php-sdk | src/Optimizely/Bucketer.php | Bucketer.findBucket | private function findBucket($bucketingId, $userId, $parentId, $trafficAllocations)
{
// Generate the bucketing key based on combination of user ID and experiment ID or group ID.
$bucketingKey = $bucketingId.$parentId;
$bucketingNumber = $this->generateBucketValue($bucketingKey);
$thi... | php | private function findBucket($bucketingId, $userId, $parentId, $trafficAllocations)
{
// Generate the bucketing key based on combination of user ID and experiment ID or group ID.
$bucketingKey = $bucketingId.$parentId;
$bucketingNumber = $this->generateBucketValue($bucketingKey);
$thi... | [
"private",
"function",
"findBucket",
"(",
"$",
"bucketingId",
",",
"$",
"userId",
",",
"$",
"parentId",
",",
"$",
"trafficAllocations",
")",
"{",
"// Generate the bucketing key based on combination of user ID and experiment ID or group ID.",
"$",
"bucketingKey",
"=",
"$",
... | @param $bucketingId string A customer-assigned value used to create the key for the murmur hash.
@param $userId string ID for user.
@param $parentId mixed ID representing Experiment or Group.
@param $trafficAllocations array Traffic allocations for variation or experiment.
@return string ID representing experiment or ... | [
"@param",
"$bucketingId",
"string",
"A",
"customer",
"-",
"assigned",
"value",
"used",
"to",
"create",
"the",
"key",
"for",
"the",
"murmur",
"hash",
".",
"@param",
"$userId",
"string",
"ID",
"for",
"user",
".",
"@param",
"$parentId",
"mixed",
"ID",
"represen... | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Bucketer.php#L114-L129 |
optimizely/php-sdk | src/Optimizely/Bucketer.php | Bucketer.bucket | public function bucket(ProjectConfig $config, Experiment $experiment, $bucketingId, $userId)
{
if (is_null($experiment->getKey())) {
return null;
}
// Determine if experiment is in a mutually exclusive group.
if ($experiment->isInMutexGroup()) {
$group = $con... | php | public function bucket(ProjectConfig $config, Experiment $experiment, $bucketingId, $userId)
{
if (is_null($experiment->getKey())) {
return null;
}
// Determine if experiment is in a mutually exclusive group.
if ($experiment->isInMutexGroup()) {
$group = $con... | [
"public",
"function",
"bucket",
"(",
"ProjectConfig",
"$",
"config",
",",
"Experiment",
"$",
"experiment",
",",
"$",
"bucketingId",
",",
"$",
"userId",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"experiment",
"->",
"getKey",
"(",
")",
")",
")",
"{",
"re... | Determine variation the user should be put in.
@param $config ProjectConfig Configuration for the project.
@param $experiment Experiment Experiment in which user is to be bucketed.
@param $bucketingId string A customer-assigned value used to create the key for the murmur hash.
@param $userId string User identifier.
@... | [
"Determine",
"variation",
"the",
"user",
"should",
"be",
"put",
"in",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Bucketer.php#L141-L204 |
optimizely/php-sdk | src/Optimizely/Entity/Variation.php | Variation.getVariableUsageById | public function getVariableUsageById($variableId)
{
if (isset($this->_variableIdToVariableUsageInstanceMap[$variableId])) {
return $this->_variableIdToVariableUsageInstanceMap[$variableId];
} else {
return null;
}
} | php | public function getVariableUsageById($variableId)
{
if (isset($this->_variableIdToVariableUsageInstanceMap[$variableId])) {
return $this->_variableIdToVariableUsageInstanceMap[$variableId];
} else {
return null;
}
} | [
"public",
"function",
"getVariableUsageById",
"(",
"$",
"variableId",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_variableIdToVariableUsageInstanceMap",
"[",
"$",
"variableId",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_variableIdToVariableUs... | @param string Variable ID
@return VariableUsage Variable usage instance corresponding to given variable ID | [
"@param",
"string",
"Variable",
"ID"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Entity/Variation.php#L122-L129 |
optimizely/php-sdk | src/Optimizely/Entity/Variation.php | Variation.generateVariableIdToVariableUsageMap | private function generateVariableIdToVariableUsageMap()
{
if (!empty($this->_variableUsageInstances)) {
foreach (array_values($this->_variableUsageInstances) as $variableUsage) {
$this->_variableIdToVariableUsageInstanceMap[$variableUsage->getId()] = $variableUsage;
}... | php | private function generateVariableIdToVariableUsageMap()
{
if (!empty($this->_variableUsageInstances)) {
foreach (array_values($this->_variableUsageInstances) as $variableUsage) {
$this->_variableIdToVariableUsageInstanceMap[$variableUsage->getId()] = $variableUsage;
}... | [
"private",
"function",
"generateVariableIdToVariableUsageMap",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_variableUsageInstances",
")",
")",
"{",
"foreach",
"(",
"array_values",
"(",
"$",
"this",
"->",
"_variableUsageInstances",
")",
"as",... | Generates variable ID to Variable usage instance map
from variable usage instances | [
"Generates",
"variable",
"ID",
"to",
"Variable",
"usage",
"instance",
"map",
"from",
"variable",
"usage",
"instances"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Entity/Variation.php#L144-L151 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.validateUserInputs | private function validateUserInputs($attributes, $eventTags = null)
{
if (!is_null($attributes) && !Validator::areAttributesValid($attributes)) {
$this->_logger->log(Logger::ERROR, 'Provided attributes are in an invalid format.');
$this->_errorHandler->handleError(
ne... | php | private function validateUserInputs($attributes, $eventTags = null)
{
if (!is_null($attributes) && !Validator::areAttributesValid($attributes)) {
$this->_logger->log(Logger::ERROR, 'Provided attributes are in an invalid format.');
$this->_errorHandler->handleError(
ne... | [
"private",
"function",
"validateUserInputs",
"(",
"$",
"attributes",
",",
"$",
"eventTags",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"attributes",
")",
"&&",
"!",
"Validator",
"::",
"areAttributesValid",
"(",
"$",
"attributes",
")",
")",... | Helper function to validate user inputs into the API methods.
@param $userId string ID for user.
@param $eventTags array Hash representing metadata associated with an event.
@return boolean Representing whether all user inputs are valid. | [
"Helper",
"function",
"to",
"validate",
"user",
"inputs",
"into",
"the",
"API",
"methods",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L173-L194 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.activate | public function activate($experimentKey, $userId, $attributes = null)
{
if (!$this->_isValid) {
$this->_logger->log(Logger::ERROR, 'Datafile has invalid format. Failing "activate".');
return null;
}
if (!$this->validateInputs(
[
self::EXPE... | php | public function activate($experimentKey, $userId, $attributes = null)
{
if (!$this->_isValid) {
$this->_logger->log(Logger::ERROR, 'Datafile has invalid format. Failing "activate".');
return null;
}
if (!$this->validateInputs(
[
self::EXPE... | [
"public",
"function",
"activate",
"(",
"$",
"experimentKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isValid",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"log",
"(",
"Logger",
"::",
... | Buckets visitor and sends impression event to Optimizely.
@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. | [
"Buckets",
"visitor",
"and",
"sends",
"impression",
"event",
"to",
"Optimizely",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L257-L283 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.track | public function track($eventKey, $userId, $attributes = null, $eventTags = null)
{
if (!$this->_isValid) {
$this->_logger->log(Logger::ERROR, 'Datafile has invalid format. Failing "track".');
return;
}
if (!$this->validateInputs(
[
self::E... | php | public function track($eventKey, $userId, $attributes = null, $eventTags = null)
{
if (!$this->_isValid) {
$this->_logger->log(Logger::ERROR, 'Datafile has invalid format. Failing "track".');
return;
}
if (!$this->validateInputs(
[
self::E... | [
"public",
"function",
"track",
"(",
"$",
"eventKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
",",
"$",
"eventTags",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isValid",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",... | Send conversion event to Optimizely.
@param $eventKey string Event key representing the event which needs to be recorded.
@param $userId string ID for user.
@param $attributes array Attributes of the user.
@param $eventTags array Hash representing metadata associated with the event. | [
"Send",
"conversion",
"event",
"to",
"Optimizely",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L293-L370 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.getVariation | 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(
[
se... | php | 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(
[
se... | [
"public",
"function",
"getVariation",
"(",
"$",
"experimentKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isValid",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"log",
"(",
"Logger",
"::... | 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",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L381-L432 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.setForcedVariation | public function setForcedVariation($experimentKey, $userId, $variationKey)
{
if (!$this->validateInputs(
[
self::EXPERIMENT_KEY =>$experimentKey,
self::USER_ID => $userId
]
)) {
return false;
}
return $this->_config-... | php | public function setForcedVariation($experimentKey, $userId, $variationKey)
{
if (!$this->validateInputs(
[
self::EXPERIMENT_KEY =>$experimentKey,
self::USER_ID => $userId
]
)) {
return false;
}
return $this->_config-... | [
"public",
"function",
"setForcedVariation",
"(",
"$",
"experimentKey",
",",
"$",
"userId",
",",
"$",
"variationKey",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateInputs",
"(",
"[",
"self",
"::",
"EXPERIMENT_KEY",
"=>",
"$",
"experimentKey",
",",
"... | Force a user into a variation for a given experiment.
@param $experimentKey string Key identifying the experiment.
@param $userId string The user ID to be used for bucketing.
@param $variationKey string The variation key specifies the variation which the user
will be forced into. If null, then clear the existing exper... | [
"Force",
"a",
"user",
"into",
"a",
"variation",
"for",
"a",
"given",
"experiment",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L444-L455 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.getForcedVariation | public function getForcedVariation($experimentKey, $userId)
{
if (!$this->validateInputs(
[
self::EXPERIMENT_KEY =>$experimentKey,
self::USER_ID => $userId
]
)) {
return null;
}
$forcedVariation = $this->_config->ge... | php | public function getForcedVariation($experimentKey, $userId)
{
if (!$this->validateInputs(
[
self::EXPERIMENT_KEY =>$experimentKey,
self::USER_ID => $userId
]
)) {
return null;
}
$forcedVariation = $this->_config->ge... | [
"public",
"function",
"getForcedVariation",
"(",
"$",
"experimentKey",
",",
"$",
"userId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateInputs",
"(",
"[",
"self",
"::",
"EXPERIMENT_KEY",
"=>",
"$",
"experimentKey",
",",
"self",
"::",
"USER_ID",
"=... | Gets the forced variation for a given user and experiment.
@param $experimentKey string Key identifying the experiment.
@param $userId string The user ID to be used for bucketing.
@return string|null The forced variation key. | [
"Gets",
"the",
"forced",
"variation",
"for",
"a",
"given",
"user",
"and",
"experiment",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L465-L482 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.isFeatureEnabled | public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
{
if (!$this->_isValid) {
$this->_logger->log(Logger::ERROR, "Datafile has invalid format. Failing '".__FUNCTION__."'.");
return false;
}
if (!$this->validateInputs(
[
... | php | public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
{
if (!$this->_isValid) {
$this->_logger->log(Logger::ERROR, "Datafile has invalid format. Failing '".__FUNCTION__."'.");
return false;
}
if (!$this->validateInputs(
[
... | [
"public",
"function",
"isFeatureEnabled",
"(",
"$",
"featureFlagKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isValid",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"log",
"(",
"Logger",
... | Determine whether a feature is enabled.
Sends an impression event if the user is bucketed into an experiment using the feature.
@param string Feature flag key
@param string User ID
@param array Associative array of user attributes
@return boolean | [
"Determine",
"whether",
"a",
"feature",
"is",
"enabled",
".",
"Sends",
"an",
"impression",
"event",
"if",
"the",
"user",
"is",
"bucketed",
"into",
"an",
"experiment",
"using",
"the",
"feature",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L494-L565 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.getEnabledFeatures | public function getEnabledFeatures($userId, $attributes = null)
{
$enabledFeatureKeys = [];
if (!$this->validateInputs(
[
self::USER_ID => $userId
]
)
) {
return $enabledFeatureKeys;
}
if (!$this->_isValid) {
... | php | public function getEnabledFeatures($userId, $attributes = null)
{
$enabledFeatureKeys = [];
if (!$this->validateInputs(
[
self::USER_ID => $userId
]
)
) {
return $enabledFeatureKeys;
}
if (!$this->_isValid) {
... | [
"public",
"function",
"getEnabledFeatures",
"(",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"enabledFeatureKeys",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"validateInputs",
"(",
"[",
"self",
"::",
"USER_ID",
"=>",
... | Get keys of all feature flags which are enabled for the user
@param string User ID
@param array Associative array of user attributes
@return array List of feature flag keys | [
"Get",
"keys",
"of",
"all",
"feature",
"flags",
"which",
"are",
"enabled",
"for",
"the",
"user"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L574-L601 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.getFeatureVariableValueForType | public function getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes = null,
$variableType = null
) {
if (!$this->validateInputs(
[
self::FEATURE_FLAG_KEY => $featureFlagKey,
self::VARIABLE_KEY... | php | public function getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes = null,
$variableType = null
) {
if (!$this->validateInputs(
[
self::FEATURE_FLAG_KEY => $featureFlagKey,
self::VARIABLE_KEY... | [
"public",
"function",
"getFeatureVariableValueForType",
"(",
"$",
"featureFlagKey",
",",
"$",
"variableKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
",",
"$",
"variableType",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valid... | Get the string value of the specified variable in the feature flag.
@param string Feature flag key
@param string Variable key
@param string User ID
@param array Associative array of user attributes
@param string Variable type
@return string Feature variable value / null | [
"Get",
"the",
"string",
"value",
"of",
"the",
"specified",
"variable",
"in",
"the",
"feature",
"flag",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L614-L723 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.getFeatureVariableBoolean | public function getFeatureVariableBoolean($featureFlagKey, $variableKey, $userId, $attributes = null)
{
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::BOOLEAN_TYPE
);
... | php | public function getFeatureVariableBoolean($featureFlagKey, $variableKey, $userId, $attributes = null)
{
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::BOOLEAN_TYPE
);
... | [
"public",
"function",
"getFeatureVariableBoolean",
"(",
"$",
"featureFlagKey",
",",
"$",
"variableKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getFeatureVariableValueForType",
"(",
"$",
"featureFlagKey",
... | Get the Boolean value of the specified variable in the feature flag.
@param string Feature flag key
@param string Variable key
@param string User ID
@param array Associative array of user attributes
@return string boolean variable value / null | [
"Get",
"the",
"Boolean",
"value",
"of",
"the",
"specified",
"variable",
"in",
"the",
"feature",
"flag",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L735-L744 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.getFeatureVariableInteger | public function getFeatureVariableInteger($featureFlagKey, $variableKey, $userId, $attributes = null)
{
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::INTEGER_TYPE
);
... | php | public function getFeatureVariableInteger($featureFlagKey, $variableKey, $userId, $attributes = null)
{
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::INTEGER_TYPE
);
... | [
"public",
"function",
"getFeatureVariableInteger",
"(",
"$",
"featureFlagKey",
",",
"$",
"variableKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getFeatureVariableValueForType",
"(",
"$",
"featureFlagKey",
... | Get the Integer value of the specified variable in the feature flag.
@param string Feature flag key
@param string Variable key
@param string User ID
@param array Associative array of user attributes
@return string integer variable value / null | [
"Get",
"the",
"Integer",
"value",
"of",
"the",
"specified",
"variable",
"in",
"the",
"feature",
"flag",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L756-L765 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.getFeatureVariableDouble | public function getFeatureVariableDouble($featureFlagKey, $variableKey, $userId, $attributes = null)
{
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::DOUBLE_TYPE
);
} | php | public function getFeatureVariableDouble($featureFlagKey, $variableKey, $userId, $attributes = null)
{
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::DOUBLE_TYPE
);
} | [
"public",
"function",
"getFeatureVariableDouble",
"(",
"$",
"featureFlagKey",
",",
"$",
"variableKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getFeatureVariableValueForType",
"(",
"$",
"featureFlagKey",
"... | Get the Double value of the specified variable in the feature flag.
@param string Feature flag key
@param string Variable key
@param string User ID
@param array Associative array of user attributes
@return string double variable value / null | [
"Get",
"the",
"Double",
"value",
"of",
"the",
"specified",
"variable",
"in",
"the",
"feature",
"flag",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L777-L786 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.getFeatureVariableString | public function getFeatureVariableString($featureFlagKey, $variableKey, $userId, $attributes = null)
{
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::STRING_TYPE
);
} | php | public function getFeatureVariableString($featureFlagKey, $variableKey, $userId, $attributes = null)
{
return $this->getFeatureVariableValueForType(
$featureFlagKey,
$variableKey,
$userId,
$attributes,
FeatureVariable::STRING_TYPE
);
} | [
"public",
"function",
"getFeatureVariableString",
"(",
"$",
"featureFlagKey",
",",
"$",
"variableKey",
",",
"$",
"userId",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getFeatureVariableValueForType",
"(",
"$",
"featureFlagKey",
"... | Get the String value of the specified variable in the feature flag.
@param string Feature flag key
@param string Variable key
@param string User ID
@param array Associative array of user attributes
@return string variable value / null | [
"Get",
"the",
"String",
"value",
"of",
"the",
"specified",
"variable",
"in",
"the",
"feature",
"flag",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L798-L807 |
optimizely/php-sdk | src/Optimizely/Optimizely.php | Optimizely.validateInputs | protected function validateInputs(array $values, $logLevel = Logger::ERROR)
{
$isValid = true;
if (array_key_exists(self::USER_ID, $values)) {
// Empty str is a valid user ID
if (!is_string($values[self::USER_ID])) {
$this->_logger->log(Logger::ERROR, sprintf(... | php | protected function validateInputs(array $values, $logLevel = Logger::ERROR)
{
$isValid = true;
if (array_key_exists(self::USER_ID, $values)) {
// Empty str is a valid user ID
if (!is_string($values[self::USER_ID])) {
$this->_logger->log(Logger::ERROR, sprintf(... | [
"protected",
"function",
"validateInputs",
"(",
"array",
"$",
"values",
",",
"$",
"logLevel",
"=",
"Logger",
"::",
"ERROR",
")",
"{",
"$",
"isValid",
"=",
"true",
";",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"USER_ID",
",",
"$",
"values",
")",
... | Calls Validator::validateNonEmptyString for each value in array
Logs for each invalid value
@param array values to validate
@param logger
@return bool True if all of the values are valid, False otherwise | [
"Calls",
"Validator",
"::",
"validateNonEmptyString",
"for",
"each",
"value",
"in",
"array",
"Logs",
"for",
"each",
"invalid",
"value"
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Optimizely.php#L831-L852 |
optimizely/php-sdk | src/Optimizely/Event/Builder/EventBuilder.php | EventBuilder.getCommonParams | private function getCommonParams($config, $userId, $attributes)
{
$visitor = [
SNAPSHOTS=> [],
VISITOR_ID => $userId,
ATTRIBUTES => []
];
$commonParams = [
ACCOUNT_ID => $config->getAccountId(),
PROJECT_ID => $config->getProjectId(... | php | private function getCommonParams($config, $userId, $attributes)
{
$visitor = [
SNAPSHOTS=> [],
VISITOR_ID => $userId,
ATTRIBUTES => []
];
$commonParams = [
ACCOUNT_ID => $config->getAccountId(),
PROJECT_ID => $config->getProjectId(... | [
"private",
"function",
"getCommonParams",
"(",
"$",
"config",
",",
"$",
"userId",
",",
"$",
"attributes",
")",
"{",
"$",
"visitor",
"=",
"[",
"SNAPSHOTS",
"=>",
"[",
"]",
",",
"VISITOR_ID",
"=>",
"$",
"userId",
",",
"ATTRIBUTES",
"=>",
"[",
"]",
"]",
... | Helper function to get parameters common to impression and conversion events.
@param $config ProjectConfig Configuration for the project.
@param $userId string ID of user.
@param $attributes array Attributes of the user.
@return array Hash representing parameters which are common to both impression and conversion eve... | [
"Helper",
"function",
"to",
"get",
"parameters",
"common",
"to",
"impression",
"and",
"conversion",
"events",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Event/Builder/EventBuilder.php#L84-L136 |
optimizely/php-sdk | src/Optimizely/Event/Builder/EventBuilder.php | EventBuilder.getImpressionParams | private function getImpressionParams(Experiment $experiment, $variationId)
{
$impressionParams = [
DECISIONS => [
[
CAMPAIGN_ID => $experiment->getLayerId(),
EXPERIMENT_ID => $experiment->getId(),
VARIATION_ID => $variat... | php | private function getImpressionParams(Experiment $experiment, $variationId)
{
$impressionParams = [
DECISIONS => [
[
CAMPAIGN_ID => $experiment->getLayerId(),
EXPERIMENT_ID => $experiment->getId(),
VARIATION_ID => $variat... | [
"private",
"function",
"getImpressionParams",
"(",
"Experiment",
"$",
"experiment",
",",
"$",
"variationId",
")",
"{",
"$",
"impressionParams",
"=",
"[",
"DECISIONS",
"=>",
"[",
"[",
"CAMPAIGN_ID",
"=>",
"$",
"experiment",
"->",
"getLayerId",
"(",
")",
",",
... | Helper function to get parameters specific to impression event.
@param $experiment Experiment Experiment being activated.
@param $variationId String ID representing the variation for the user.
@return array Hash representing parameters particular to impression event. | [
"Helper",
"function",
"to",
"get",
"parameters",
"specific",
"to",
"impression",
"event",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Event/Builder/EventBuilder.php#L146-L169 |
optimizely/php-sdk | src/Optimizely/Event/Builder/EventBuilder.php | EventBuilder.getConversionParams | private function getConversionParams($eventEntity, $eventTags)
{
$conversionParams = [];
$singleSnapshot = [];
$eventDict = [
ENTITY_ID => $eventEntity->getId(),
TIMESTAMP => time()*1000,
UUID => GeneratorUtils::getRandomUuid(),
KEY => $eventE... | php | private function getConversionParams($eventEntity, $eventTags)
{
$conversionParams = [];
$singleSnapshot = [];
$eventDict = [
ENTITY_ID => $eventEntity->getId(),
TIMESTAMP => time()*1000,
UUID => GeneratorUtils::getRandomUuid(),
KEY => $eventE... | [
"private",
"function",
"getConversionParams",
"(",
"$",
"eventEntity",
",",
"$",
"eventTags",
")",
"{",
"$",
"conversionParams",
"=",
"[",
"]",
";",
"$",
"singleSnapshot",
"=",
"[",
"]",
";",
"$",
"eventDict",
"=",
"[",
"ENTITY_ID",
"=>",
"$",
"eventEntity... | Helper function to get parameters specific to conversion event.
@param $eventEntity Event representing event entity.
@param $eventTags array Hash representing metadata associated with the event.
@return array Hash representing parameters particular to conversion event. | [
"Helper",
"function",
"to",
"get",
"parameters",
"specific",
"to",
"conversion",
"event",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Event/Builder/EventBuilder.php#L179-L211 |
optimizely/php-sdk | src/Optimizely/Event/Builder/EventBuilder.php | EventBuilder.createImpressionEvent | public function createImpressionEvent($config, $experimentKey, $variationKey, $userId, $attributes)
{
$eventParams = $this->getCommonParams($config, $userId, $attributes);
$experiment = $config->getExperimentFromKey($experimentKey);
$variation = $config->getVariationFromKey($experimentKey, ... | php | public function createImpressionEvent($config, $experimentKey, $variationKey, $userId, $attributes)
{
$eventParams = $this->getCommonParams($config, $userId, $attributes);
$experiment = $config->getExperimentFromKey($experimentKey);
$variation = $config->getVariationFromKey($experimentKey, ... | [
"public",
"function",
"createImpressionEvent",
"(",
"$",
"config",
",",
"$",
"experimentKey",
",",
"$",
"variationKey",
",",
"$",
"userId",
",",
"$",
"attributes",
")",
"{",
"$",
"eventParams",
"=",
"$",
"this",
"->",
"getCommonParams",
"(",
"$",
"config",
... | Create impression event to be sent to the logging endpoint.
@param $config ProjectConfig Configuration for the project.
@param $experimentKey Experiment Experiment being activated.
@param $variationKey string Variation user
@param $userId string ID of user.
@param $attributes array Attributes of the user.
@return Log... | [
"Create",
"impression",
"event",
"to",
"be",
"sent",
"to",
"the",
"logging",
"endpoint",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Event/Builder/EventBuilder.php#L224-L235 |
optimizely/php-sdk | src/Optimizely/Event/Builder/EventBuilder.php | EventBuilder.createConversionEvent | public function createConversionEvent($config, $eventKey, $userId, $attributes, $eventTags)
{
$eventParams = $this->getCommonParams($config, $userId, $attributes);
$eventEntity = $config->getEvent($eventKey);
$conversionParams = $this->getConversionParams($eventEntity, $eventTags);
... | php | public function createConversionEvent($config, $eventKey, $userId, $attributes, $eventTags)
{
$eventParams = $this->getCommonParams($config, $userId, $attributes);
$eventEntity = $config->getEvent($eventKey);
$conversionParams = $this->getConversionParams($eventEntity, $eventTags);
... | [
"public",
"function",
"createConversionEvent",
"(",
"$",
"config",
",",
"$",
"eventKey",
",",
"$",
"userId",
",",
"$",
"attributes",
",",
"$",
"eventTags",
")",
"{",
"$",
"eventParams",
"=",
"$",
"this",
"->",
"getCommonParams",
"(",
"$",
"config",
",",
... | Create conversion event to be sent to the logging endpoint.
@param $config ProjectConfig Configuration for the project.
@param $eventKey string Key representing the event.
@param $userId string ID of user.
@param $attributes array Attributes of the user.
@param $eventTags array Hash representing metadata associated wi... | [
"Create",
"conversion",
"event",
"to",
"be",
"sent",
"to",
"the",
"logging",
"endpoint",
"."
] | train | https://github.com/optimizely/php-sdk/blob/6bc0c7b1372e22926f5d7c1a439fe334c1c6e1db/src/Optimizely/Event/Builder/EventBuilder.php#L248-L256 |
Rias500/craft-contact-form-extensions | src/controllers/SubmissionsController.php | SubmissionsController.actionShowSubmission | public function actionShowSubmission(string $submissionId = null, string $siteHandle = null)
{
$query = new ContactFormSubmissionQuery(ContactFormSubmission::class);
$query->id = $submissionId;
/* @var ContactFormSubmission $submission */
$submission = $query->one();
$messa... | php | public function actionShowSubmission(string $submissionId = null, string $siteHandle = null)
{
$query = new ContactFormSubmissionQuery(ContactFormSubmission::class);
$query->id = $submissionId;
/* @var ContactFormSubmission $submission */
$submission = $query->one();
$messa... | [
"public",
"function",
"actionShowSubmission",
"(",
"string",
"$",
"submissionId",
"=",
"null",
",",
"string",
"$",
"siteHandle",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"new",
"ContactFormSubmissionQuery",
"(",
"ContactFormSubmission",
"::",
"class",
")",
";",... | @param string|null $submissionId
@param string|null $siteHandle
@return \yii\web\Response | [
"@param",
"string|null",
"$submissionId",
"@param",
"string|null",
"$siteHandle"
] | train | https://github.com/Rias500/craft-contact-form-extensions/blob/84485252eba7e9aaf4ca917a2da0226f78863762/src/controllers/SubmissionsController.php#L18-L34 |
Rias500/craft-contact-form-extensions | src/migrations/Install.php | Install.safeDown | public function safeDown()
{
$this->driver = Craft::$app->getConfig()->getDb()->driver;
$this->removeTables();
return true;
} | php | public function safeDown()
{
$this->driver = Craft::$app->getConfig()->getDb()->driver;
$this->removeTables();
return true;
} | [
"public",
"function",
"safeDown",
"(",
")",
"{",
"$",
"this",
"->",
"driver",
"=",
"Craft",
"::",
"$",
"app",
"->",
"getConfig",
"(",
")",
"->",
"getDb",
"(",
")",
"->",
"driver",
";",
"$",
"this",
"->",
"removeTables",
"(",
")",
";",
"return",
"tr... | This method contains the logic to be executed when removing this migration.
This method differs from [[down()]] in that the DB logic implemented here will
be enclosed within a DB transaction.
Child classes may implement this method instead of [[down()]] if the DB logic
needs to be within a transaction.
@return bool re... | [
"This",
"method",
"contains",
"the",
"logic",
"to",
"be",
"executed",
"when",
"removing",
"this",
"migration",
".",
"This",
"method",
"differs",
"from",
"[[",
"down",
"()",
"]]",
"in",
"that",
"the",
"DB",
"logic",
"implemented",
"here",
"will",
"be",
"enc... | train | https://github.com/Rias500/craft-contact-form-extensions/blob/84485252eba7e9aaf4ca917a2da0226f78863762/src/migrations/Install.php#L77-L83 |
Rias500/craft-contact-form-extensions | src/ContactFormExtensions.php | ContactFormExtensions.init | public function init()
{
parent::init();
self::$plugin = $this;
if (!Craft::$app->plugins->isPluginInstalled('contact-form') && !Craft::$app->request->getIsConsoleRequest()) {
Craft::$app->session->setNotice(Craft::t('contact-form-extensions', 'The Contact Form plugin is not ins... | php | public function init()
{
parent::init();
self::$plugin = $this;
if (!Craft::$app->plugins->isPluginInstalled('contact-form') && !Craft::$app->request->getIsConsoleRequest()) {
Craft::$app->session->setNotice(Craft::t('contact-form-extensions', 'The Contact Form plugin is not ins... | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"self",
"::",
"$",
"plugin",
"=",
"$",
"this",
";",
"if",
"(",
"!",
"Craft",
"::",
"$",
"app",
"->",
"plugins",
"->",
"isPluginInstalled",
"(",
"'contact-form'",
")",... | Set our $plugin static property to this class so that it can be accessed via
CraftContactFormExtensions::$plugin.
Called after the plugin class is instantiated; do any one-time initialization
here such as hooks and events.
If you have a '/vendor/autoload.php' file, it will be loaded for you automatically;
you do not ... | [
"Set",
"our",
"$plugin",
"static",
"property",
"to",
"this",
"class",
"so",
"that",
"it",
"can",
"be",
"accessed",
"via",
"CraftContactFormExtensions",
"::",
"$plugin",
"."
] | train | https://github.com/Rias500/craft-contact-form-extensions/blob/84485252eba7e9aaf4ca917a2da0226f78863762/src/ContactFormExtensions.php#L79-L200 |
Rias500/craft-contact-form-extensions | src/ContactFormExtensions.php | ContactFormExtensions.getCpNavItem | public function getCpNavItem()
{
if (!$this->settings->enableDatabase) {
return;
}
$navItem = parent::getCpNavItem();
$navItem['label'] = Craft::t('contact-form-extensions', 'Form Submissions');
return $navItem;
} | php | public function getCpNavItem()
{
if (!$this->settings->enableDatabase) {
return;
}
$navItem = parent::getCpNavItem();
$navItem['label'] = Craft::t('contact-form-extensions', 'Form Submissions');
return $navItem;
} | [
"public",
"function",
"getCpNavItem",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"settings",
"->",
"enableDatabase",
")",
"{",
"return",
";",
"}",
"$",
"navItem",
"=",
"parent",
"::",
"getCpNavItem",
"(",
")",
";",
"$",
"navItem",
"[",
"'label'"... | {@inheritdoc} | [
"{"
] | train | https://github.com/Rias500/craft-contact-form-extensions/blob/84485252eba7e9aaf4ca917a2da0226f78863762/src/ContactFormExtensions.php#L205-L216 |
Rias500/craft-contact-form-extensions | src/services/ContactFormExtensionsService.php | ContactFormExtensionsService.saveSubmission | public function saveSubmission(Submission $submission)
{
$contactFormSubmission = new ContactFormSubmission();
$contactFormSubmission->form = $submission->message['formName'] ?? 'contact';
$contactFormSubmission->fromName = $submission->fromName;
$contactFormSubmission->fromEmail = $... | php | public function saveSubmission(Submission $submission)
{
$contactFormSubmission = new ContactFormSubmission();
$contactFormSubmission->form = $submission->message['formName'] ?? 'contact';
$contactFormSubmission->fromName = $submission->fromName;
$contactFormSubmission->fromEmail = $... | [
"public",
"function",
"saveSubmission",
"(",
"Submission",
"$",
"submission",
")",
"{",
"$",
"contactFormSubmission",
"=",
"new",
"ContactFormSubmission",
"(",
")",
";",
"$",
"contactFormSubmission",
"->",
"form",
"=",
"$",
"submission",
"->",
"message",
"[",
"'... | This function can literally be anything you want, and you can have as many service
functions as you want.
From any other plugin file, call it like this:
CraftContactFormExtensions::$plugin->craftContactFormExtensionsService->exampleService()
@param Submission $submission
@throws Exception
@throws \Throwable
@throws... | [
"This",
"function",
"can",
"literally",
"be",
"anything",
"you",
"want",
"and",
"you",
"can",
"have",
"as",
"many",
"service",
"functions",
"as",
"you",
"want",
"."
] | train | https://github.com/Rias500/craft-contact-form-extensions/blob/84485252eba7e9aaf4ca917a2da0226f78863762/src/services/ContactFormExtensionsService.php#L57-L77 |
Rias500/craft-contact-form-extensions | src/services/ContactFormExtensionsService.php | ContactFormExtensionsService.utf8AllTheThings | public function utf8AllTheThings(array $things): array
{
foreach ($things as $key => $value) {
$things[$key] = $this->utf8Value($value);
}
return $things;
} | php | public function utf8AllTheThings(array $things): array
{
foreach ($things as $key => $value) {
$things[$key] = $this->utf8Value($value);
}
return $things;
} | [
"public",
"function",
"utf8AllTheThings",
"(",
"array",
"$",
"things",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"things",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"things",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"utf8Value",
... | @param array $things
@return array | [
"@param",
"array",
"$things"
] | train | https://github.com/Rias500/craft-contact-form-extensions/blob/84485252eba7e9aaf4ca917a2da0226f78863762/src/services/ContactFormExtensionsService.php#L111-L118 |
Rias500/craft-contact-form-extensions | src/services/ContactFormExtensionsService.php | ContactFormExtensionsService.utf8Value | public function utf8Value($value)
{
if (is_array($value)) {
return $this->utf8AllTheThings($value);
}
return StringHelper::convertToUtf8($value);
} | php | public function utf8Value($value)
{
if (is_array($value)) {
return $this->utf8AllTheThings($value);
}
return StringHelper::convertToUtf8($value);
} | [
"public",
"function",
"utf8Value",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"utf8AllTheThings",
"(",
"$",
"value",
")",
";",
"}",
"return",
"StringHelper",
"::",
"convertToUtf8",
... | @param array|string $value
@return array|string | [
"@param",
"array|string",
"$value"
] | train | https://github.com/Rias500/craft-contact-form-extensions/blob/84485252eba7e9aaf4ca917a2da0226f78863762/src/services/ContactFormExtensionsService.php#L125-L132 |
Rias500/craft-contact-form-extensions | src/elements/ContactFormSubmission.php | ContactFormSubmission.afterSave | public function afterSave(bool $isNew)
{
if ($isNew) {
Craft::$app->db->createCommand()
->insert('{{%contactform_submissions}}', [
'id' => $this->id,
'form' => $this->form,
'subject' => $this->subject,
... | php | public function afterSave(bool $isNew)
{
if ($isNew) {
Craft::$app->db->createCommand()
->insert('{{%contactform_submissions}}', [
'id' => $this->id,
'form' => $this->form,
'subject' => $this->subject,
... | [
"public",
"function",
"afterSave",
"(",
"bool",
"$",
"isNew",
")",
"{",
"if",
"(",
"$",
"isNew",
")",
"{",
"Craft",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"insert",
"(",
"'{{%contactform_submissions}}'",
",",
"[",
"'id'",
... | @param bool $isNew
@throws \yii\db\Exception | [
"@param",
"bool",
"$isNew"
] | train | https://github.com/Rias500/craft-contact-form-extensions/blob/84485252eba7e9aaf4ca917a2da0226f78863762/src/elements/ContactFormSubmission.php#L206-L232 |
morrislaptop/laravel-queue-clear | src/Clearer.php | Clearer.clear | public function clear($connection, $queue)
{
$count = 0;
$connection = $this->manager->connection($connection);
while ($job = $connection->pop($queue)) {
$job->delete();
$count++;
}
return $count;
} | php | public function clear($connection, $queue)
{
$count = 0;
$connection = $this->manager->connection($connection);
while ($job = $connection->pop($queue)) {
$job->delete();
$count++;
}
return $count;
} | [
"public",
"function",
"clear",
"(",
"$",
"connection",
",",
"$",
"queue",
")",
"{",
"$",
"count",
"=",
"0",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"manager",
"->",
"connection",
"(",
"$",
"connection",
")",
";",
"while",
"(",
"$",
"job",
"... | {@inheritDoc} | [
"{"
] | train | https://github.com/morrislaptop/laravel-queue-clear/blob/ea814b360322fcdf2e9397b7a77b1ce4e96423a4/src/Clearer.php#L25-L36 |
morrislaptop/laravel-queue-clear | src/Console/QueueClearCommand.php | QueueClearCommand.handle | public function handle()
{
$connection = $this->argument('connection') ?: $this->config->get('queue.default');
$queue = $this->argument('queue') ?: $this->config->get('queue.connections.' . $connection . '.queue');
$this->info(sprintf('Clearing queue "%s" on "%s"', $queue, $connection));
$cleared = $this->cl... | php | public function handle()
{
$connection = $this->argument('connection') ?: $this->config->get('queue.default');
$queue = $this->argument('queue') ?: $this->config->get('queue.connections.' . $connection . '.queue');
$this->info(sprintf('Clearing queue "%s" on "%s"', $queue, $connection));
$cleared = $this->cl... | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"connection",
"=",
"$",
"this",
"->",
"argument",
"(",
"'connection'",
")",
"?",
":",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'queue.default'",
")",
";",
"$",
"queue",
"=",
"$",
"this",
"->"... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/morrislaptop/laravel-queue-clear/blob/ea814b360322fcdf2e9397b7a77b1ce4e96423a4/src/Console/QueueClearCommand.php#L70-L78 |
egeloen/ivory-http-adapter | src/Event/BasicAuth/BasicAuth.php | BasicAuth.authenticate | public function authenticate(InternalRequestInterface $internalRequest)
{
if (!$this->match($internalRequest)) {
return $internalRequest;
}
return $internalRequest->withHeader(
'Authorization',
'Basic '.base64_encode($this->username.':'.$this->password)
... | php | public function authenticate(InternalRequestInterface $internalRequest)
{
if (!$this->match($internalRequest)) {
return $internalRequest;
}
return $internalRequest->withHeader(
'Authorization',
'Basic '.base64_encode($this->username.':'.$this->password)
... | [
"public",
"function",
"authenticate",
"(",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"match",
"(",
"$",
"internalRequest",
")",
")",
"{",
"return",
"$",
"internalRequest",
";",
"}",
"return",
"$",
"inter... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/BasicAuth/BasicAuth.php#L107-L117 |
egeloen/ivory-http-adapter | src/Event/BasicAuth/BasicAuth.php | BasicAuth.match | private function match(InternalRequestInterface $request)
{
return !$this->hasMatcher()
|| (is_string($this->matcher) && preg_match($this->matcher, (string) $request->getUri()))
|| (is_callable($this->matcher) && call_user_func($this->matcher, $request));
} | php | private function match(InternalRequestInterface $request)
{
return !$this->hasMatcher()
|| (is_string($this->matcher) && preg_match($this->matcher, (string) $request->getUri()))
|| (is_callable($this->matcher) && call_user_func($this->matcher, $request));
} | [
"private",
"function",
"match",
"(",
"InternalRequestInterface",
"$",
"request",
")",
"{",
"return",
"!",
"$",
"this",
"->",
"hasMatcher",
"(",
")",
"||",
"(",
"is_string",
"(",
"$",
"this",
"->",
"matcher",
")",
"&&",
"preg_match",
"(",
"$",
"this",
"->... | @param InternalRequestInterface $request
@return bool | [
"@param",
"InternalRequestInterface",
"$request"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/BasicAuth/BasicAuth.php#L124-L129 |
egeloen/ivory-http-adapter | src/Event/Redirect/Redirect.php | Redirect.createRedirectRequest | public function createRedirectRequest(
ResponseInterface $response,
InternalRequestInterface $internalRequest,
HttpAdapterInterface $httpAdapter
) {
if ($response->getStatusCode() < 300
|| $response->getStatusCode() >= 400
|| !$response->hasHeader('Location'))... | php | public function createRedirectRequest(
ResponseInterface $response,
InternalRequestInterface $internalRequest,
HttpAdapterInterface $httpAdapter
) {
if ($response->getStatusCode() < 300
|| $response->getStatusCode() >= 400
|| !$response->hasHeader('Location'))... | [
"public",
"function",
"createRedirectRequest",
"(",
"ResponseInterface",
"$",
"response",
",",
"InternalRequestInterface",
"$",
"internalRequest",
",",
"HttpAdapterInterface",
"$",
"httpAdapter",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Redirect/Redirect.php#L102-L159 |
egeloen/ivory-http-adapter | src/Event/Redirect/Redirect.php | Redirect.prepareResponse | public function prepareResponse(ResponseInterface $response, InternalRequestInterface $internalRequest)
{
return $response
->withParameter(self::REDIRECT_COUNT, (int) $internalRequest->getParameter(self::REDIRECT_COUNT))
->withParameter(self::EFFECTIVE_URI, (string) $internalRequest-... | php | public function prepareResponse(ResponseInterface $response, InternalRequestInterface $internalRequest)
{
return $response
->withParameter(self::REDIRECT_COUNT, (int) $internalRequest->getParameter(self::REDIRECT_COUNT))
->withParameter(self::EFFECTIVE_URI, (string) $internalRequest-... | [
"public",
"function",
"prepareResponse",
"(",
"ResponseInterface",
"$",
"response",
",",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"return",
"$",
"response",
"->",
"withParameter",
"(",
"self",
"::",
"REDIRECT_COUNT",
",",
"(",
"int",
")",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Redirect/Redirect.php#L164-L169 |
egeloen/ivory-http-adapter | src/Event/Redirect/Redirect.php | Redirect.getRootRequest | private function getRootRequest(InternalRequestInterface $internalRequest)
{
if ($internalRequest->hasParameter(self::PARENT_REQUEST)) {
return $this->getRootRequest($internalRequest->getParameter(self::PARENT_REQUEST));
}
return $internalRequest;
} | php | private function getRootRequest(InternalRequestInterface $internalRequest)
{
if ($internalRequest->hasParameter(self::PARENT_REQUEST)) {
return $this->getRootRequest($internalRequest->getParameter(self::PARENT_REQUEST));
}
return $internalRequest;
} | [
"private",
"function",
"getRootRequest",
"(",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"if",
"(",
"$",
"internalRequest",
"->",
"hasParameter",
"(",
"self",
"::",
"PARENT_REQUEST",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getRootRequest",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Redirect/Redirect.php#L174-L181 |
egeloen/ivory-http-adapter | src/MockHttpAdapter.php | MockHttpAdapter.sendInternalRequest | protected function sendInternalRequest(InternalRequestInterface $internalRequest)
{
if (count($this->queuedResponses) <= 0) {
throw new \OutOfBoundsException('You must append a response in the queue before sending a request.');
}
$this->receivedRequests[] = $internalRequest;
... | php | protected function sendInternalRequest(InternalRequestInterface $internalRequest)
{
if (count($this->queuedResponses) <= 0) {
throw new \OutOfBoundsException('You must append a response in the queue before sending a request.');
}
$this->receivedRequests[] = $internalRequest;
... | [
"protected",
"function",
"sendInternalRequest",
"(",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"queuedResponses",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'You m... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/MockHttpAdapter.php#L74-L83 |
egeloen/ivory-http-adapter | src/HttpAdapterFactory.php | HttpAdapterFactory.register | public static function register($name, $class, $client = null)
{
if (!in_array('Ivory\HttpAdapter\HttpAdapterInterface', class_implements($class), true)) {
throw HttpAdapterException::httpAdapterMustImplementInterface($class);
}
$adapter = ['adapter' => $class];
if ($cl... | php | public static function register($name, $class, $client = null)
{
if (!in_array('Ivory\HttpAdapter\HttpAdapterInterface', class_implements($class), true)) {
throw HttpAdapterException::httpAdapterMustImplementInterface($class);
}
$adapter = ['adapter' => $class];
if ($cl... | [
"public",
"static",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"class",
",",
"$",
"client",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"'Ivory\\HttpAdapter\\HttpAdapterInterface'",
",",
"class_implements",
"(",
"$",
"class",
")",
",",
... | @param string $name
@param string $class
@param string|null $client
@throws HttpAdapterException | [
"@param",
"string",
"$name",
"@param",
"string",
"$class",
"@param",
"string|null",
"$client"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/HttpAdapterFactory.php#L115-L129 |
egeloen/ivory-http-adapter | src/HttpAdapterFactory.php | HttpAdapterFactory.capable | public static function capable($name)
{
return isset(self::$adapters[$name])
&& (!isset(self::$adapters[$name]['client'])
|| (class_exists(self::$adapters[$name]['client'])
|| function_exists(self::$adapters[$name]['client'])
|| ini_get(self::$adapters[$name][... | php | public static function capable($name)
{
return isset(self::$adapters[$name])
&& (!isset(self::$adapters[$name]['client'])
|| (class_exists(self::$adapters[$name]['client'])
|| function_exists(self::$adapters[$name]['client'])
|| ini_get(self::$adapters[$name][... | [
"public",
"static",
"function",
"capable",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"self",
"::",
"$",
"adapters",
"[",
"$",
"name",
"]",
")",
"&&",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"adapters",
"[",
"$",
"name",
"]",
"[",
"'c... | @param string $name
@return bool | [
"@param",
"string",
"$name"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/HttpAdapterFactory.php#L144-L151 |
egeloen/ivory-http-adapter | src/HttpAdapterFactory.php | HttpAdapterFactory.create | public static function create($name)
{
if (!isset(self::$adapters[$name])) {
throw HttpAdapterException::httpAdapterDoesNotExist($name);
}
if (!self::capable($name)) {
throw HttpAdapterException::httpAdapterIsNotUsable($name);
}
return new self::$ada... | php | public static function create($name)
{
if (!isset(self::$adapters[$name])) {
throw HttpAdapterException::httpAdapterDoesNotExist($name);
}
if (!self::capable($name)) {
throw HttpAdapterException::httpAdapterIsNotUsable($name);
}
return new self::$ada... | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"adapters",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"HttpAdapterException",
"::",
"httpAdapterDoesNotExist",
"(",
"$",
"name",
... | @param string $name
@throws HttpAdapterException
@return HttpAdapterInterface | [
"@param",
"string",
"$name"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/HttpAdapterFactory.php#L160-L171 |
egeloen/ivory-http-adapter | src/HttpAdapterFactory.php | HttpAdapterFactory.guess | public static function guess($preferred = [])
{
$adapters = self::$adapters;
foreach ((array) $preferred as $preference) {
if (self::capable($preference)) {
return self::create($preference);
}
unset($adapters[$preference]);
}
for... | php | public static function guess($preferred = [])
{
$adapters = self::$adapters;
foreach ((array) $preferred as $preference) {
if (self::capable($preference)) {
return self::create($preference);
}
unset($adapters[$preference]);
}
for... | [
"public",
"static",
"function",
"guess",
"(",
"$",
"preferred",
"=",
"[",
"]",
")",
"{",
"$",
"adapters",
"=",
"self",
"::",
"$",
"adapters",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"preferred",
"as",
"$",
"preference",
")",
"{",
"if",
"(",
"s... | @param string|array $preferred
@throws HttpAdapterException
@return HttpAdapterInterface | [
"@param",
"string|array",
"$preferred"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/HttpAdapterFactory.php#L180-L199 |
egeloen/ivory-http-adapter | src/Event/Cache/Adapter/StashCacheAdapter.php | StashCacheAdapter.set | public function set($id, $data, $lifeTime = 0)
{
$result = $this->pool->getItem($id)->set($data, $lifeTime);
$this->pool->flush();
return $result;
} | php | public function set($id, $data, $lifeTime = 0)
{
$result = $this->pool->getItem($id)->set($data, $lifeTime);
$this->pool->flush();
return $result;
} | [
"public",
"function",
"set",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"lifeTime",
"=",
"0",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"pool",
"->",
"getItem",
"(",
"$",
"id",
")",
"->",
"set",
"(",
"$",
"data",
",",
"$",
"lifeTime",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Adapter/StashCacheAdapter.php#L53-L59 |
egeloen/ivory-http-adapter | src/Event/Cache/Adapter/StashCacheAdapter.php | StashCacheAdapter.remove | public function remove($id)
{
$result = $this->pool->getItem($id)->clear();
$this->pool->flush();
return $result;
} | php | public function remove($id)
{
$result = $this->pool->getItem($id)->clear();
$this->pool->flush();
return $result;
} | [
"public",
"function",
"remove",
"(",
"$",
"id",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"pool",
"->",
"getItem",
"(",
"$",
"id",
")",
"->",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"pool",
"->",
"flush",
"(",
")",
";",
"return",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Adapter/StashCacheAdapter.php#L64-L70 |
egeloen/ivory-http-adapter | src/BuzzHttpAdapter.php | BuzzHttpAdapter.sendInternalRequest | protected function sendInternalRequest(InternalRequestInterface $internalRequest)
{
$this->browser->getClient()->setTimeout($this->getConfiguration()->getTimeout());
$this->browser->getClient()->setMaxRedirects(0);
$request = $this->browser->getMessageFactory()->createRequest(
$... | php | protected function sendInternalRequest(InternalRequestInterface $internalRequest)
{
$this->browser->getClient()->setTimeout($this->getConfiguration()->getTimeout());
$this->browser->getClient()->setMaxRedirects(0);
$request = $this->browser->getMessageFactory()->createRequest(
$... | [
"protected",
"function",
"sendInternalRequest",
"(",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"$",
"this",
"->",
"browser",
"->",
"getClient",
"(",
")",
"->",
"setTimeout",
"(",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
"->",
"getTime... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/BuzzHttpAdapter.php#L64-L95 |
egeloen/ivory-http-adapter | src/Message/MessageTrait.php | MessageTrait.withAddedParameter | public function withAddedParameter($name, $value)
{
$new = clone $this;
$new->parameters[$name] = $new->hasParameter($name)
? array_merge((array) $new->parameters[$name], (array) $value)
: $value;
return $new;
} | php | public function withAddedParameter($name, $value)
{
$new = clone $this;
$new->parameters[$name] = $new->hasParameter($name)
? array_merge((array) $new->parameters[$name], (array) $value)
: $value;
return $new;
} | [
"public",
"function",
"withAddedParameter",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"parameters",
"[",
"$",
"name",
"]",
"=",
"$",
"new",
"->",
"hasParameter",
"(",
"$",
"name",
"... | @param string $name
@param mixed $value
@return object | [
"@param",
"string",
"$name",
"@param",
"mixed",
"$value"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Message/MessageTrait.php#L72-L80 |
egeloen/ivory-http-adapter | src/Event/Subscriber/LoggerSubscriber.php | LoggerSubscriber.debug | private function debug(
HttpAdapterInterface $httpAdapter,
InternalRequestInterface $request,
ResponseInterface $response
) {
$request = $this->getTimer()->stop($request);
$this->logger->debug(
sprintf(
'Send "%s %s" in %.2f ms.',
... | php | private function debug(
HttpAdapterInterface $httpAdapter,
InternalRequestInterface $request,
ResponseInterface $response
) {
$request = $this->getTimer()->stop($request);
$this->logger->debug(
sprintf(
'Send "%s %s" in %.2f ms.',
... | [
"private",
"function",
"debug",
"(",
"HttpAdapterInterface",
"$",
"httpAdapter",
",",
"InternalRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getTimer",
"(",
")",
"->",
"stop",
"... | @param HttpAdapterInterface $httpAdapter
@param InternalRequestInterface $request
@param ResponseInterface $response
@return InternalRequestInterface | [
"@param",
"HttpAdapterInterface",
"$httpAdapter",
"@param",
"InternalRequestInterface",
"$request",
"@param",
"ResponseInterface",
"$response"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Subscriber/LoggerSubscriber.php#L142-L164 |
egeloen/ivory-http-adapter | src/Event/Subscriber/LoggerSubscriber.php | LoggerSubscriber.error | private function error(HttpAdapterInterface $httpAdapter, HttpAdapterException $exception)
{
$request = $this->getTimer()->stop($exception->getRequest());
$this->logger->error(
sprintf(
'Unable to send "%s %s".',
$exception->getRequest()->getMethod(),
... | php | private function error(HttpAdapterInterface $httpAdapter, HttpAdapterException $exception)
{
$request = $this->getTimer()->stop($exception->getRequest());
$this->logger->error(
sprintf(
'Unable to send "%s %s".',
$exception->getRequest()->getMethod(),
... | [
"private",
"function",
"error",
"(",
"HttpAdapterInterface",
"$",
"httpAdapter",
",",
"HttpAdapterException",
"$",
"exception",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getTimer",
"(",
")",
"->",
"stop",
"(",
"$",
"exception",
"->",
"getRequest",
"... | @param HttpAdapterInterface $httpAdapter
@param HttpAdapterException $exception
@return InternalRequestInterface | [
"@param",
"HttpAdapterInterface",
"$httpAdapter",
"@param",
"HttpAdapterException",
"$exception"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Subscriber/LoggerSubscriber.php#L172-L193 |
egeloen/ivory-http-adapter | src/Event/Cache/Cache.php | Cache.cacheException | public function cacheException($cacheException = null)
{
if ($cacheException !== null) {
$this->cacheException = $cacheException;
}
return $this->cacheException;
} | php | public function cacheException($cacheException = null)
{
if ($cacheException !== null) {
$this->cacheException = $cacheException;
}
return $this->cacheException;
} | [
"public",
"function",
"cacheException",
"(",
"$",
"cacheException",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"cacheException",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"cacheException",
"=",
"$",
"cacheException",
";",
"}",
"return",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Cache.php#L116-L123 |
egeloen/ivory-http-adapter | src/Event/Cache/Cache.php | Cache.getResponse | public function getResponse(InternalRequestInterface $internalRequest, MessageFactoryInterface $messageFactory)
{
if (!$this->adapter->has($id = $this->getIdentifier($internalRequest, 'response'))) {
return;
}
$response = $this->unserializeResponse($this->adapter->get($id), $mes... | php | public function getResponse(InternalRequestInterface $internalRequest, MessageFactoryInterface $messageFactory)
{
if (!$this->adapter->has($id = $this->getIdentifier($internalRequest, 'response'))) {
return;
}
$response = $this->unserializeResponse($this->adapter->get($id), $mes... | [
"public",
"function",
"getResponse",
"(",
"InternalRequestInterface",
"$",
"internalRequest",
",",
"MessageFactoryInterface",
"$",
"messageFactory",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"->",
"has",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Cache.php#L128-L137 |
egeloen/ivory-http-adapter | src/Event/Cache/Cache.php | Cache.getException | public function getException(InternalRequestInterface $internalRequest, MessageFactoryInterface $messageFactory)
{
if (!$this->cacheException || !$this->adapter->has($id = $this->getIdentifier($internalRequest, 'exception'))) {
return;
}
$exception = $this->unserializeException(... | php | public function getException(InternalRequestInterface $internalRequest, MessageFactoryInterface $messageFactory)
{
if (!$this->cacheException || !$this->adapter->has($id = $this->getIdentifier($internalRequest, 'exception'))) {
return;
}
$exception = $this->unserializeException(... | [
"public",
"function",
"getException",
"(",
"InternalRequestInterface",
"$",
"internalRequest",
",",
"MessageFactoryInterface",
"$",
"messageFactory",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cacheException",
"||",
"!",
"$",
"this",
"->",
"adapter",
"->",
"h... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Cache.php#L142-L152 |
egeloen/ivory-http-adapter | src/Event/Cache/Cache.php | Cache.saveResponse | public function saveResponse(ResponseInterface $response, InternalRequestInterface $internalRequest)
{
if (!$this->adapter->has($id = $this->getIdentifier($internalRequest, 'response'))) {
$this->adapter->set($id, $this->serializeResponse($response), $this->lifetime);
}
} | php | public function saveResponse(ResponseInterface $response, InternalRequestInterface $internalRequest)
{
if (!$this->adapter->has($id = $this->getIdentifier($internalRequest, 'response'))) {
$this->adapter->set($id, $this->serializeResponse($response), $this->lifetime);
}
} | [
"public",
"function",
"saveResponse",
"(",
"ResponseInterface",
"$",
"response",
",",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"->",
"has",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"getIdentif... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Cache.php#L157-L162 |
egeloen/ivory-http-adapter | src/Event/Cache/Cache.php | Cache.saveException | public function saveException(HttpAdapterException $exception, InternalRequestInterface $internalRequest)
{
if ($this->cacheException && !$this->adapter->has($id = $this->getIdentifier($internalRequest, 'exception'))) {
$this->adapter->set($id, $this->serializeException($exception), $this->lifet... | php | public function saveException(HttpAdapterException $exception, InternalRequestInterface $internalRequest)
{
if ($this->cacheException && !$this->adapter->has($id = $this->getIdentifier($internalRequest, 'exception'))) {
$this->adapter->set($id, $this->serializeException($exception), $this->lifet... | [
"public",
"function",
"saveException",
"(",
"HttpAdapterException",
"$",
"exception",
",",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheException",
"&&",
"!",
"$",
"this",
"->",
"adapter",
"->",
"has",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Cache.php#L167-L172 |
egeloen/ivory-http-adapter | src/Event/Cache/Cache.php | Cache.serializeInternalRequest | private function serializeInternalRequest(InternalRequestInterface $internalRequest)
{
$formattedInternalRequest = $this->formatter->formatRequest($internalRequest);
unset($formattedInternalRequest['parameters']);
return $this->serialize($formattedInternalRequest);
} | php | private function serializeInternalRequest(InternalRequestInterface $internalRequest)
{
$formattedInternalRequest = $this->formatter->formatRequest($internalRequest);
unset($formattedInternalRequest['parameters']);
return $this->serialize($formattedInternalRequest);
} | [
"private",
"function",
"serializeInternalRequest",
"(",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"$",
"formattedInternalRequest",
"=",
"$",
"this",
"->",
"formatter",
"->",
"formatRequest",
"(",
"$",
"internalRequest",
")",
";",
"unset",
"(",
"$... | @param InternalRequestInterface $internalRequest
@return string | [
"@param",
"InternalRequestInterface",
"$internalRequest"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Cache.php#L190-L196 |
egeloen/ivory-http-adapter | src/Event/Cache/Cache.php | Cache.unserializeResponse | private function unserializeResponse($serialized, MessageFactoryInterface $messageFactory)
{
return $this->createResponse($this->unserialize($serialized), $messageFactory);
} | php | private function unserializeResponse($serialized, MessageFactoryInterface $messageFactory)
{
return $this->createResponse($this->unserialize($serialized), $messageFactory);
} | [
"private",
"function",
"unserializeResponse",
"(",
"$",
"serialized",
",",
"MessageFactoryInterface",
"$",
"messageFactory",
")",
"{",
"return",
"$",
"this",
"->",
"createResponse",
"(",
"$",
"this",
"->",
"unserialize",
"(",
"$",
"serialized",
")",
",",
"$",
... | @param string $serialized
@param MessageFactoryInterface $messageFactory
@return ResponseInterface | [
"@param",
"string",
"$serialized",
"@param",
"MessageFactoryInterface",
"$messageFactory"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Cache.php#L224-L227 |
egeloen/ivory-http-adapter | src/Event/Cache/Cache.php | Cache.createResponse | private function createResponse(array $unserialized, MessageFactoryInterface $messageFactory)
{
return $messageFactory->createResponse(
$unserialized['status_code'],
$unserialized['protocol_version'],
$unserialized['headers'],
$unserialized['body'],
... | php | private function createResponse(array $unserialized, MessageFactoryInterface $messageFactory)
{
return $messageFactory->createResponse(
$unserialized['status_code'],
$unserialized['protocol_version'],
$unserialized['headers'],
$unserialized['body'],
... | [
"private",
"function",
"createResponse",
"(",
"array",
"$",
"unserialized",
",",
"MessageFactoryInterface",
"$",
"messageFactory",
")",
"{",
"return",
"$",
"messageFactory",
"->",
"createResponse",
"(",
"$",
"unserialized",
"[",
"'status_code'",
"]",
",",
"$",
"un... | @param array $unserialized
@param MessageFactoryInterface $messageFactory
@return ResponseInterface | [
"@param",
"array",
"$unserialized",
"@param",
"MessageFactoryInterface",
"$messageFactory"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/Event/Cache/Cache.php#L245-L254 |
egeloen/ivory-http-adapter | src/SocketHttpAdapter.php | SocketHttpAdapter.sendInternalRequest | protected function sendInternalRequest(InternalRequestInterface $internalRequest)
{
$uri = $internalRequest->getUri();
$https = $uri->getScheme() === 'https';
$socket = @stream_socket_client(
($https ? 'ssl' : 'tcp').'://'.$uri->getHost().':'.($uri->getPort() ?: ($https ? 443 : ... | php | protected function sendInternalRequest(InternalRequestInterface $internalRequest)
{
$uri = $internalRequest->getUri();
$https = $uri->getScheme() === 'https';
$socket = @stream_socket_client(
($https ? 'ssl' : 'tcp').'://'.$uri->getHost().':'.($uri->getPort() ?: ($https ? 443 : ... | [
"protected",
"function",
"sendInternalRequest",
"(",
"InternalRequestInterface",
"$",
"internalRequest",
")",
"{",
"$",
"uri",
"=",
"$",
"internalRequest",
"->",
"getUri",
"(",
")",
";",
"$",
"https",
"=",
"$",
"uri",
"->",
"getScheme",
"(",
")",
"===",
"'ht... | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/ivory-http-adapter/blob/2387f532049d8c6c439e68097abc6f7b33f027a4/src/SocketHttpAdapter.php#L36-L72 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.