Skip to content

Develop #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 6 additions & 140 deletions src/SplitIO/Sdk/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,37 +168,7 @@ private function doEvaluation($operation, $metricName, $key, $featureName, $attr
}

/**
* Returns the treatment to show this id for this feature.
* The set of treatments for a feature can be configured
* on the Split web console.
* This method returns the string 'control' if:
* <ol>
* <li>Any of the parameters were null</li>
* <li>There was an exception</li>
* <li>The SDK does not know this feature</li>
* <li>The feature was deleted through the web console.</li>
* </ol>
* 'control' is a reserved treatment, to highlight these
* exceptional circumstances.
*
* <p>
* The sdk returns the default treatment of this feature if:
* <ol>
* <li>The feature was killed</li>
* <li>The id did not match any of the conditions in the
* feature roll-out plan</li>
* </ol>
* The default treatment of a feature is set on the Split web
* console.
*
* <p>
* This method does not throw any exceptions.
* It also never returns null.
*
* @param $key
* @param $featureName
* @param $attributes
* @return string
* @inheritdoc
*/
public function getTreatment($key, $featureName, array $attributes = null)
{
Expand All @@ -218,42 +188,7 @@ public function getTreatment($key, $featureName, array $attributes = null)
}

/**
* Returns an object with the treatment to show this id for this feature
* and the config provided.
* The set of treatments and config for a feature can be configured
* on the Split web console.
* This method returns the string 'control' if:
* <ol>
* <li>Any of the parameters were null</li>
* <li>There was an exception</li>
* <li>The SDK does not know this feature</li>
* <li>The feature was deleted through the web console.</li>
* </ol>
* 'control' is a reserved treatment, to highlight these
* exceptional circumstances.
*
* <p>
* The sdk returns the default treatment of this feature if:
* <ol>
* <li>The feature was killed</li>
* <li>The id did not match any of the conditions in the
* feature roll-out plan</li>
* </ol>
* The default treatment of a feature is set on the Split web
* console.
*
* <p>
* This method does not throw any exceptions.
* It also never returns null.
*
* This method returns null configuration if:
* <ol>
* <li>config was not set up</li>
* </ol>
* @param $key
* @param $featureName
* @param $attributes
* @return string
* @inheritdoc
*/
public function getTreatmentWithConfig($key, $featureName, array $attributes = null)
{
Expand Down Expand Up @@ -388,35 +323,7 @@ private function doEvaluationForTreatments($operation, $metricName, $key, $featu
}

/**
* Returns an associative array which each key will be
* the treatment result for each feature passed as parameter.
* The set of treatments for a feature can be configured
* on the Split web console.
* This method returns the string 'control' if:
* <ol>
* <li>featureNames is invalid/li>
* </ol>
* 'control' is a reserved treatment, to highlight these
* exceptional circumstances.
*
* <p>
* The sdk returns the default treatment of this feature if:
* <ol>
* <li>The feature was killed</li>
* <li>The id did not match any of the conditions in the
* feature roll-out plan</li>
* </ol>
* The default treatment of a feature is set on the Split web
* console.
*
* <p>
* This method does not throw any exceptions.
* It also never returns null.
*
* @param $key
* @param $featureNames
* @param $attributes
* @return array|control
* @inheritdoc
*/
public function getTreatments($key, $featureNames, array $attributes = null)
{
Expand All @@ -434,44 +341,14 @@ function ($feature) {
)
);
} catch (\Exception $e) {
SplitApp::logger()->critical('getTreatmens method is throwing exceptions');
SplitApp::logger()->critical('getTreatments method is throwing exceptions');
$splitNames = InputValidator::validateFeatureNames($featureNames, 'getTreatments');
return is_null($splitNames) ? array() : array_fill_keys($splitNames, TreatmentEnum::CONTROL);
}
}

/**
* Returns an associative array which each key will be
* the treatment result and the config for each
* feature passed as parameter.
* The set of treatments for a feature can be configured
* on the Split web console and the config for
* that treatment.
* This method returns the string 'control' if:
* <ol>
* <li>featureNames is invalid/li>
* </ol>
* 'control' is a reserved treatment, to highlight these
* exceptional circumstances.
*
* <p>
* The sdk returns the default treatment of this feature if:
* <ol>
* <li>The feature was killed</li>
* <li>The id did not match any of the conditions in the
* feature roll-out plan</li>
* </ol>
* The default treatment of a feature is set on the Split web
* console.
*
* <p>
* This method does not throw any exceptions.
* It also never returns null.
*
* @param $key
* @param $featureNames
* @param $attributes
* @return array|control
* @inheritdoc
*/
public function getTreatmentsWithConfig($key, $featureNames, array $attributes = null)
{
Expand All @@ -492,18 +369,7 @@ public function getTreatmentsWithConfig($key, $featureNames, array $attributes =
}

/**
* A short-hand for
* <pre>
* (getTreatment(key, feature) == treatment) ? true : false;
* </pre>
*
* This method never throws exceptions.
* Instead of throwing exceptions, it returns false.
*
* @param $key
* @param $featureName
* @param $treatment
* @return bool
* @inheritdoc
*/
public function isTreatment($key, $featureName, $treatment)
{
Expand Down
108 changes: 108 additions & 0 deletions src/SplitIO/Sdk/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,114 @@ interface ClientInterface
*/
public function getTreatment($key, $featureName, array $attributes = null);

/**
* Returns an object with the treatment to show this id for this feature
* and the config provided.
* The set of treatments and config for a feature can be configured
* on the Split web console.
* This method returns the string 'control' if:
* <ol>
* <li>Any of the parameters were null</li>
* <li>There was an exception</li>
* <li>The SDK does not know this feature</li>
* <li>The feature was deleted through the web console.</li>
* </ol>
* 'control' is a reserved treatment, to highlight these
* exceptional circumstances.
*
* <p>
* The sdk returns the default treatment of this feature if:
* <ol>
* <li>The feature was killed</li>
* <li>The id did not match any of the conditions in the
* feature roll-out plan</li>
* </ol>
* The default treatment of a feature is set on the Split web
* console.
*
* <p>
* This method does not throw any exceptions.
* It also never returns null.
*
* This method returns null configuration if:
* <ol>
* <li>config was not set up</li>
* </ol>
* @param $key
* @param $featureName
* @param $attributes
* @return string
*/
public function getTreatmentWithConfig($key, $featureName, array $attributes = null);

/**
* Returns an associative array which each key will be
* the treatment result for each feature passed as parameter.
* The set of treatments for a feature can be configured
* on the Split web console.
* This method returns the string 'control' if:
* <ol>
* <li>featureNames is invalid/li>
* </ol>
* 'control' is a reserved treatment, to highlight these
* exceptional circumstances.
*
* <p>
* The sdk returns the default treatment of this feature if:
* <ol>
* <li>The feature was killed</li>
* <li>The id did not match any of the conditions in the
* feature roll-out plan</li>
* </ol>
* The default treatment of a feature is set on the Split web
* console.
*
* <p>
* This method does not throw any exceptions.
* It also never returns null.
*
* @param $key
* @param $featureNames
* @param $attributes
* @return array
*/
public function getTreatments($key, $featureNames, array $attributes = null);

/**
* Returns an associative array which each key will be
* the treatment result and the config for each
* feature passed as parameter.
* The set of treatments for a feature can be configured
* on the Split web console and the config for
* that treatment.
* This method returns the string 'control' if:
* <ol>
* <li>featureNames is invalid/li>
* </ol>
* 'control' is a reserved treatment, to highlight these
* exceptional circumstances.
*
* <p>
* The sdk returns the default treatment of this feature if:
* <ol>
* <li>The feature was killed</li>
* <li>The id did not match any of the conditions in the
* feature roll-out plan</li>
* </ol>
* The default treatment of a feature is set on the Split web
* console.
*
* <p>
* This method does not throw any exceptions.
* It also never returns null.
*
* @param $key
* @param $featureNames
* @param $attributes
* @return array
*/
public function getTreatmentsWithConfig($key, $featureNames, array $attributes = null);

/**
* A short-hand for
* <pre>
Expand Down
52 changes: 13 additions & 39 deletions src/SplitIO/Sdk/LocalhostClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,7 @@ public function doValidation($key, $featureName, $operation)
}

/**
* Returns the treatment to show this id for this feature.
* The set of treatments for a feature can be configured
* on the Split web console.
* This method returns the string 'control' if:
* <ol>
* <li>Any of the parameters were null</li>
* <li>There was an exception</li>
* <li>The SDK does not know this feature</li>
* <li>The feature was deleted through the web console.</li>
* </ol>
* 'control' is a reserved treatment, to highlight these
* exceptional circumstances.
*
* <p>
* The sdk returns the default treatment of this feature if:
* <ol>
* <li>The feature was killed</li>
* <li>The id did not match any of the conditions in the
* feature roll-out plan</li>
* </ol>
* The default treatment of a feature is set on the Split web
* console.
*
* <p>
* This method does not throw any exceptions.
* It also never returns null.
*
* @param $key
* @param $featureName
* @return string
* @inheritdoc
*/
public function getTreatment($key, $featureName, array $attributes = null)
{
Expand All @@ -183,6 +154,9 @@ public function getTreatment($key, $featureName, array $attributes = null)
return TreatmentEnum::CONTROL;
}

/**
* @inheritdoc
*/
public function getTreatmentWithConfig($key, $featureName, array $attributes = null)
{
$treatmentResult = array(
Expand Down Expand Up @@ -212,7 +186,10 @@ public function getTreatmentWithConfig($key, $featureName, array $attributes = n
return $treatmentResult;
}

public function getTreatments($key, $featureNames, $attributes = null)
/**
* @inheritdoc
*/
public function getTreatments($key, $featureNames, array $attributes = null)
{
$splitNames = InputValidator::validateFeatureNames($featureNames, "getTreatments");
if (is_null($splitNames)) {
Expand All @@ -233,7 +210,10 @@ public function getTreatments($key, $featureNames, $attributes = null)
return $result;
}

public function getTreatmentsWithConfig($key, $featureNames, $attributes = null)
/**
* @inheritdoc
*/
public function getTreatmentsWithConfig($key, $featureNames, array $attributes = null)
{
$splitNames = InputValidator::validateFeatureNames($featureNames, "getTreatmentsWithConfig");
if (is_null($splitNames)) {
Expand All @@ -255,13 +235,7 @@ public function getTreatmentsWithConfig($key, $featureNames, $attributes = null)
}

/**
* This method never throws exceptions.
* Instead of throwing exceptions, it returns false.
*
* @param $key
* @param $featureName
* @param $treatment
* @return bool
* @inheritdoc
*/
public function isTreatment($key, $featureName, $treatment)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class Version
{
const CURRENT = '6.2.3';
const CURRENT = '6.2.4';
}