@@ -43,11 +43,6 @@ class Client implements ClientInterface
4343 */
4444 private $ eventCache ;
4545
46- /**
47- * @var \SplitIO\Sdk\Validator\InputValidator
48- */
49- private $ inputValidator ;
50-
5146 /**
5247 * @param array $options
5348 * @param array $storages
@@ -66,7 +61,6 @@ public function __construct($storages, $options = array())
6661 $ this ->queueMetadata = new QueueMetadataMessage (
6762 isset ($ options ['IPAddressesEnabled ' ]) ? $ options ['IPAddressesEnabled ' ] : true
6863 );
69- $ this ->inputValidator = new InputValidator ($ this ->splitCache );
7064 }
7165
7266 /**
@@ -103,17 +97,17 @@ private function createImpression($key, $feature, $treatment, $changeNumber, $la
10397 */
10498 private function doInputValidationForTreatment ($ key , $ featureName , array $ attributes = null , $ operation )
10599 {
106- $ key = $ this -> inputValidator -> validateKey ($ key , $ operation );
100+ $ key = InputValidator:: validateKey ($ key , $ operation );
107101 if (is_null ($ key )) {
108102 return null ;
109103 }
110104
111- $ featureName = $ this -> inputValidator -> validateFeatureName ($ featureName , $ operation );
105+ $ featureName = InputValidator:: validateFeatureName ($ featureName , $ operation );
112106 if (is_null ($ featureName )) {
113107 return null ;
114108 }
115109
116- if (!$ this -> inputValidator -> validAttributes ($ attributes , $ operation )) {
110+ if (!InputValidator:: validAttributes ($ attributes , $ operation )) {
117111 return null ;
118112 }
119113
@@ -148,7 +142,7 @@ private function doEvaluation($operation, $metricName, $key, $featureName, $attr
148142 $ featureName = $ inputValidation ['featureName ' ];
149143 try {
150144 $ result = $ this ->evaluator ->evaluateFeature ($ matchingKey , $ bucketingKey , $ featureName , $ attributes );
151- if (!$ this -> inputValidator -> isSplitFound ($ result ['impression ' ]['label ' ], $ featureName , $ operation )) {
145+ if (!InputValidator:: isSplitFound ($ result ['impression ' ]['label ' ], $ featureName , $ operation )) {
152146 return $ default ;
153147 }
154148 // Creates impression
@@ -244,13 +238,13 @@ public function getTreatmentWithConfig($key, $featureName, array $attributes = n
244238 */
245239 private function doInputValidationForTreatments ($ key , $ featureNames , array $ attributes = null , $ operation )
246240 {
247- $ splitNames = $ this -> inputValidator -> validateFeatureNames ($ featureNames , $ operation );
241+ $ splitNames = InputValidator:: validateFeatureNames ($ featureNames , $ operation );
248242 if (is_null ($ splitNames )) {
249243 return null ;
250244 }
251245
252- $ key = $ this -> inputValidator -> validateKey ($ key , $ operation );
253- if (is_null ($ key ) || !$ this -> inputValidator -> validAttributes ($ attributes , $ operation )) {
246+ $ key = InputValidator:: validateKey ($ key , $ operation );
247+ if (is_null ($ key ) || !InputValidator:: validAttributes ($ attributes , $ operation )) {
254248 return array (
255249 'controlTreatments ' => array_fill_keys (
256250 $ splitNames ,
@@ -320,7 +314,7 @@ private function doEvaluationForTreatments($operation, $metricName, $key, $featu
320314 $ attributes
321315 );
322316 foreach ($ evaluationResults ['evaluations ' ] as $ splitName => $ evalResult ) {
323- if ($ this -> inputValidator -> isSplitFound ($ evalResult ['impression ' ]['label ' ], $ splitName , $ operation )) {
317+ if (InputValidator:: isSplitFound ($ evalResult ['impression ' ]['label ' ], $ splitName , $ operation )) {
324318 // Creates impression
325319 $ impressions [] = $ this ->createImpression (
326320 $ matchingKey ,
@@ -368,7 +362,7 @@ function ($feature) {
368362 );
369363 } catch (\Exception $ e ) {
370364 SplitApp::logger ()->critical ('getTreatments method is throwing exceptions ' );
371- $ splitNames = $ this -> inputValidator -> validateFeatureNames ($ featureNames , 'getTreatments ' );
365+ $ splitNames = InputValidator:: validateFeatureNames ($ featureNames , 'getTreatments ' );
372366 return is_null ($ splitNames ) ? array () : array_fill_keys ($ splitNames , TreatmentEnum::CONTROL );
373367 }
374368 }
@@ -388,7 +382,7 @@ public function getTreatmentsWithConfig($key, $featureNames, array $attributes =
388382 );
389383 } catch (\Exception $ e ) {
390384 SplitApp::logger ()->critical ('getTreatmentsWithConfig method is throwing exceptions ' );
391- $ splitNames = $ this -> inputValidator -> validateFeatureNames ($ featureNames , 'getTreatmentsWithConfig ' );
385+ $ splitNames = InputValidator:: validateFeatureNames ($ featureNames , 'getTreatmentsWithConfig ' );
392386 return is_null ($ splitNames ) ? array () :
393387 array_fill_keys ($ splitNames , array ('treatment ' => TreatmentEnum::CONTROL , 'config ' => null ));
394388 }
@@ -423,11 +417,11 @@ public function isTreatment($key, $featureName, $treatment)
423417 */
424418 public function track ($ key , $ trafficType , $ eventType , $ value = null , $ properties = null )
425419 {
426- $ key = $ this -> inputValidator -> validateTrackKey ($ key );
427- $ trafficType = $ this ->inputValidator -> validateTrafficType ( $ trafficType );
428- $ eventType = $ this -> inputValidator -> validateEventType ($ eventType );
429- $ value = $ this -> inputValidator -> validateValue ($ value );
430- $ properties = $ this -> inputValidator -> validProperties ($ properties );
420+ $ key = InputValidator:: validateTrackKey ($ key );
421+ $ trafficType = InputValidator:: validateTrafficType ( $ this ->splitCache , $ trafficType );
422+ $ eventType = InputValidator:: validateEventType ($ eventType );
423+ $ value = InputValidator:: validateValue ($ value );
424+ $ properties = InputValidator:: validProperties ($ properties );
431425
432426 if (is_null ($ key ) || is_null ($ trafficType ) || is_null ($ eventType ) || $ value === false
433427 || $ properties === false ) {
0 commit comments