Skip to content

Commit 5b34d0d

Browse files
authored
Merge pull request #145 from splitio/fix/ClientInterface
Fix/client interface
2 parents 8f2bdfa + 4864cfb commit 5b34d0d

File tree

6 files changed

+137
-184
lines changed

6 files changed

+137
-184
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2018 Split Software, Co.
1+
Copyright © 2020 Split Software, Inc.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
"authors": [
77
{
88
"name": "Split",
9-
"homepage": "http://split.io"
9+
"homepage": "https://www.split.io/",
10+
"email": "php@split.io"
1011
},
1112
{
12-
"name": "Sebastian Arrubia",
13-
"email": "sebastian@split.io"
13+
"name": "Martin Redolatti",
14+
"email": "martin.redolatti@split.io"
15+
},
16+
{
17+
"name": "Matias Melograno",
18+
"email": "matias.melograno@split.io"
1419
}
1520
],
1621

src/SplitIO/Sdk/Client.php

Lines changed: 6 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -168,37 +168,7 @@ private function doEvaluation($operation, $metricName, $key, $featureName, $attr
168168
}
169169

170170
/**
171-
* Returns the treatment to show this id for this feature.
172-
* The set of treatments for a feature can be configured
173-
* on the Split web console.
174-
* This method returns the string 'control' if:
175-
* <ol>
176-
* <li>Any of the parameters were null</li>
177-
* <li>There was an exception</li>
178-
* <li>The SDK does not know this feature</li>
179-
* <li>The feature was deleted through the web console.</li>
180-
* </ol>
181-
* 'control' is a reserved treatment, to highlight these
182-
* exceptional circumstances.
183-
*
184-
* <p>
185-
* The sdk returns the default treatment of this feature if:
186-
* <ol>
187-
* <li>The feature was killed</li>
188-
* <li>The id did not match any of the conditions in the
189-
* feature roll-out plan</li>
190-
* </ol>
191-
* The default treatment of a feature is set on the Split web
192-
* console.
193-
*
194-
* <p>
195-
* This method does not throw any exceptions.
196-
* It also never returns null.
197-
*
198-
* @param $key
199-
* @param $featureName
200-
* @param $attributes
201-
* @return string
171+
* @inheritdoc
202172
*/
203173
public function getTreatment($key, $featureName, array $attributes = null)
204174
{
@@ -218,42 +188,7 @@ public function getTreatment($key, $featureName, array $attributes = null)
218188
}
219189

220190
/**
221-
* Returns an object with the treatment to show this id for this feature
222-
* and the config provided.
223-
* The set of treatments and config for a feature can be configured
224-
* on the Split web console.
225-
* This method returns the string 'control' if:
226-
* <ol>
227-
* <li>Any of the parameters were null</li>
228-
* <li>There was an exception</li>
229-
* <li>The SDK does not know this feature</li>
230-
* <li>The feature was deleted through the web console.</li>
231-
* </ol>
232-
* 'control' is a reserved treatment, to highlight these
233-
* exceptional circumstances.
234-
*
235-
* <p>
236-
* The sdk returns the default treatment of this feature if:
237-
* <ol>
238-
* <li>The feature was killed</li>
239-
* <li>The id did not match any of the conditions in the
240-
* feature roll-out plan</li>
241-
* </ol>
242-
* The default treatment of a feature is set on the Split web
243-
* console.
244-
*
245-
* <p>
246-
* This method does not throw any exceptions.
247-
* It also never returns null.
248-
*
249-
* This method returns null configuration if:
250-
* <ol>
251-
* <li>config was not set up</li>
252-
* </ol>
253-
* @param $key
254-
* @param $featureName
255-
* @param $attributes
256-
* @return string
191+
* @inheritdoc
257192
*/
258193
public function getTreatmentWithConfig($key, $featureName, array $attributes = null)
259194
{
@@ -388,35 +323,7 @@ private function doEvaluationForTreatments($operation, $metricName, $key, $featu
388323
}
389324

390325
/**
391-
* Returns an associative array which each key will be
392-
* the treatment result for each feature passed as parameter.
393-
* The set of treatments for a feature can be configured
394-
* on the Split web console.
395-
* This method returns the string 'control' if:
396-
* <ol>
397-
* <li>featureNames is invalid/li>
398-
* </ol>
399-
* 'control' is a reserved treatment, to highlight these
400-
* exceptional circumstances.
401-
*
402-
* <p>
403-
* The sdk returns the default treatment of this feature if:
404-
* <ol>
405-
* <li>The feature was killed</li>
406-
* <li>The id did not match any of the conditions in the
407-
* feature roll-out plan</li>
408-
* </ol>
409-
* The default treatment of a feature is set on the Split web
410-
* console.
411-
*
412-
* <p>
413-
* This method does not throw any exceptions.
414-
* It also never returns null.
415-
*
416-
* @param $key
417-
* @param $featureNames
418-
* @param $attributes
419-
* @return array|control
326+
* @inheritdoc
420327
*/
421328
public function getTreatments($key, $featureNames, array $attributes = null)
422329
{
@@ -434,44 +341,14 @@ function ($feature) {
434341
)
435342
);
436343
} catch (\Exception $e) {
437-
SplitApp::logger()->critical('getTreatmens method is throwing exceptions');
344+
SplitApp::logger()->critical('getTreatments method is throwing exceptions');
438345
$splitNames = InputValidator::validateFeatureNames($featureNames, 'getTreatments');
439346
return is_null($splitNames) ? array() : array_fill_keys($splitNames, TreatmentEnum::CONTROL);
440347
}
441348
}
442349

443350
/**
444-
* Returns an associative array which each key will be
445-
* the treatment result and the config for each
446-
* feature passed as parameter.
447-
* The set of treatments for a feature can be configured
448-
* on the Split web console and the config for
449-
* that treatment.
450-
* This method returns the string 'control' if:
451-
* <ol>
452-
* <li>featureNames is invalid/li>
453-
* </ol>
454-
* 'control' is a reserved treatment, to highlight these
455-
* exceptional circumstances.
456-
*
457-
* <p>
458-
* The sdk returns the default treatment of this feature if:
459-
* <ol>
460-
* <li>The feature was killed</li>
461-
* <li>The id did not match any of the conditions in the
462-
* feature roll-out plan</li>
463-
* </ol>
464-
* The default treatment of a feature is set on the Split web
465-
* console.
466-
*
467-
* <p>
468-
* This method does not throw any exceptions.
469-
* It also never returns null.
470-
*
471-
* @param $key
472-
* @param $featureNames
473-
* @param $attributes
474-
* @return array|control
351+
* @inheritdoc
475352
*/
476353
public function getTreatmentsWithConfig($key, $featureNames, array $attributes = null)
477354
{
@@ -492,18 +369,7 @@ public function getTreatmentsWithConfig($key, $featureNames, array $attributes =
492369
}
493370

494371
/**
495-
* A short-hand for
496-
* <pre>
497-
* (getTreatment(key, feature) == treatment) ? true : false;
498-
* </pre>
499-
*
500-
* This method never throws exceptions.
501-
* Instead of throwing exceptions, it returns false.
502-
*
503-
* @param $key
504-
* @param $featureName
505-
* @param $treatment
506-
* @return bool
372+
* @inheritdoc
507373
*/
508374
public function isTreatment($key, $featureName, $treatment)
509375
{

src/SplitIO/Sdk/ClientInterface.php

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,114 @@ interface ClientInterface
3838
*/
3939
public function getTreatment($key, $featureName, array $attributes = null);
4040

41+
/**
42+
* Returns an object with the treatment to show this id for this feature
43+
* and the config provided.
44+
* The set of treatments and config for a feature can be configured
45+
* on the Split web console.
46+
* This method returns the string 'control' if:
47+
* <ol>
48+
* <li>Any of the parameters were null</li>
49+
* <li>There was an exception</li>
50+
* <li>The SDK does not know this feature</li>
51+
* <li>The feature was deleted through the web console.</li>
52+
* </ol>
53+
* 'control' is a reserved treatment, to highlight these
54+
* exceptional circumstances.
55+
*
56+
* <p>
57+
* The sdk returns the default treatment of this feature if:
58+
* <ol>
59+
* <li>The feature was killed</li>
60+
* <li>The id did not match any of the conditions in the
61+
* feature roll-out plan</li>
62+
* </ol>
63+
* The default treatment of a feature is set on the Split web
64+
* console.
65+
*
66+
* <p>
67+
* This method does not throw any exceptions.
68+
* It also never returns null.
69+
*
70+
* This method returns null configuration if:
71+
* <ol>
72+
* <li>config was not set up</li>
73+
* </ol>
74+
* @param $key
75+
* @param $featureName
76+
* @param $attributes
77+
* @return string
78+
*/
79+
public function getTreatmentWithConfig($key, $featureName, array $attributes = null);
80+
81+
/**
82+
* Returns an associative array which each key will be
83+
* the treatment result for each feature passed as parameter.
84+
* The set of treatments for a feature can be configured
85+
* on the Split web console.
86+
* This method returns the string 'control' if:
87+
* <ol>
88+
* <li>featureNames is invalid/li>
89+
* </ol>
90+
* 'control' is a reserved treatment, to highlight these
91+
* exceptional circumstances.
92+
*
93+
* <p>
94+
* The sdk returns the default treatment of this feature if:
95+
* <ol>
96+
* <li>The feature was killed</li>
97+
* <li>The id did not match any of the conditions in the
98+
* feature roll-out plan</li>
99+
* </ol>
100+
* The default treatment of a feature is set on the Split web
101+
* console.
102+
*
103+
* <p>
104+
* This method does not throw any exceptions.
105+
* It also never returns null.
106+
*
107+
* @param $key
108+
* @param $featureNames
109+
* @param $attributes
110+
* @return array
111+
*/
112+
public function getTreatments($key, $featureNames, array $attributes = null);
113+
114+
/**
115+
* Returns an associative array which each key will be
116+
* the treatment result and the config for each
117+
* feature passed as parameter.
118+
* The set of treatments for a feature can be configured
119+
* on the Split web console and the config for
120+
* that treatment.
121+
* This method returns the string 'control' if:
122+
* <ol>
123+
* <li>featureNames is invalid/li>
124+
* </ol>
125+
* 'control' is a reserved treatment, to highlight these
126+
* exceptional circumstances.
127+
*
128+
* <p>
129+
* The sdk returns the default treatment of this feature if:
130+
* <ol>
131+
* <li>The feature was killed</li>
132+
* <li>The id did not match any of the conditions in the
133+
* feature roll-out plan</li>
134+
* </ol>
135+
* The default treatment of a feature is set on the Split web
136+
* console.
137+
*
138+
* <p>
139+
* This method does not throw any exceptions.
140+
* It also never returns null.
141+
*
142+
* @param $key
143+
* @param $featureNames
144+
* @param $attributes
145+
* @return array
146+
*/
147+
public function getTreatmentsWithConfig($key, $featureNames, array $attributes = null);
148+
41149
/**
42150
* A short-hand for
43151
* <pre>

0 commit comments

Comments
 (0)