Skip to content
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2018 Split Software, Co.
Copyright © 2020 Split Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
"authors": [
{
"name": "Split",
"homepage": "http://split.io"
"homepage": "https://www.split.io/",
"email": "php@split.io"
},
{
"name": "Sebastian Arrubia",
"email": "sebastian@split.io"
"name": "Martin Redolatti",
"email": "martin.redolatti@split.io"
},
{
"name": "Matias Melograno",
"email": "matias.melograno@split.io"
}
],

Expand Down
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
Loading