@@ -93,6 +93,16 @@ class DatafileProjectConfig implements ProjectConfigInterface
9393 */
9494 private $ datafile ;
9595
96+ /**
97+ * @var string environmentKey of the config.
98+ */
99+ private $ environmentKey ;
100+
101+ /**
102+ * @var string sdkKey of the config.
103+ */
104+ private $ sdkKey ;
105+
96106 /**
97107 * @var string Revision of the datafile.
98108 */
@@ -172,6 +182,34 @@ class DatafileProjectConfig implements ProjectConfigInterface
172182 */
173183 private $ _rollouts ;
174184
185+ /**
186+ * list of Attributes that will be parsed from the datafile
187+ *
188+ * @var [Attribute]
189+ */
190+ private $ attributes ;
191+
192+ /**
193+ * list of Audiences that will be parsed from the datafile
194+ *
195+ * @var [Audience]
196+ */
197+ private $ audiences ;
198+
199+ /**
200+ * list of Events that will be parsed from the datafile
201+ *
202+ * @var [Event]
203+ */
204+ private $ events ;
205+
206+ /**
207+ * list of Typed Audiences that will be parsed from the datafile
208+ *
209+ * @var [Audience]
210+ */
211+ private $ typedAudiences ;
212+
175213 /**
176214 * internal mapping of feature keys to feature flag models.
177215 *
@@ -222,6 +260,8 @@ public function __construct($datafile, $logger, $errorHandler)
222260 $ this ->_logger = $ logger ;
223261 $ this ->_errorHandler = $ errorHandler ;
224262 $ this ->_version = $ config ['version ' ];
263+ $ this ->environmentKey = isset ($ config ['environmentKey ' ]) ? $ config ['environmentKey ' ] : '' ;
264+ $ this ->sdkKey = isset ($ config ['sdkKey ' ]) ? $ config ['sdkKey ' ] : '' ;
225265 if (!in_array ($ this ->_version , $ supportedVersions )) {
226266 throw new InvalidDatafileVersionException (
227267 "This version of the PHP SDK does not support the given datafile version: {$ this ->_version }. "
@@ -237,10 +277,10 @@ public function __construct($datafile, $logger, $errorHandler)
237277
238278 $ groups = $ config ['groups ' ] ?: [];
239279 $ experiments = $ config ['experiments ' ] ?: [];
240- $ events = $ config ['events ' ] ? : [];
241- $ attributes = $ config ['attributes ' ] ? : [];
242- $ audiences = $ config ['audiences ' ] ? : [];
243- $ typedAudiences = isset ($ config ['typedAudiences ' ]) ? $ config ['typedAudiences ' ]: [];
280+ $ this -> attributes = isset ( $ config ['attributes ' ]) ? $ config [ ' attributes ' ] : [];
281+ $ this -> audiences = isset ( $ config ['audiences ' ]) ? $ config [ ' audiences ' ] : [];
282+ $ this -> events = isset ( $ config ['events ' ]) ? $ config [ ' events ' ] : [];
283+ $ this -> typedAudiences = isset ($ config ['typedAudiences ' ]) ? $ config ['typedAudiences ' ] : [];
244284 $ rollouts = isset ($ config ['rollouts ' ]) ? $ config ['rollouts ' ] : [];
245285 $ featureFlags = isset ($ config ['featureFlags ' ]) ? $ config ['featureFlags ' ]: [];
246286
@@ -258,10 +298,10 @@ public function __construct($datafile, $logger, $errorHandler)
258298
259299 $ this ->_groupIdMap = ConfigParser::generateMap ($ groups , 'id ' , Group::class);
260300 $ this ->_experimentIdMap = ConfigParser::generateMap ($ experiments , 'id ' , Experiment::class);
261- $ this ->_eventKeyMap = ConfigParser::generateMap ($ events , 'key ' , Event::class);
262- $ this ->_attributeKeyMap = ConfigParser::generateMap ($ attributes , 'key ' , Attribute::class);
263- $ typedAudienceIdMap = ConfigParser::generateMap ($ typedAudiences , 'id ' , Audience::class);
264- $ this ->_audienceIdMap = ConfigParser::generateMap ($ audiences , 'id ' , Audience::class);
301+ $ this ->_eventKeyMap = ConfigParser::generateMap ($ this -> events , 'key ' , Event::class);
302+ $ this ->_attributeKeyMap = ConfigParser::generateMap ($ this -> attributes , 'key ' , Attribute::class);
303+ $ typedAudienceIdMap = ConfigParser::generateMap ($ this -> typedAudiences , 'id ' , Audience::class);
304+ $ this ->_audienceIdMap = ConfigParser::generateMap ($ this -> audiences , 'id ' , Audience::class);
265305 $ this ->_rollouts = ConfigParser::generateMap ($ rollouts , null , Rollout::class);
266306 $ this ->_featureFlags = ConfigParser::generateMap ($ featureFlags , null , FeatureFlag::class);
267307
@@ -449,6 +489,22 @@ public function getRevision()
449489 return $ this ->_revision ;
450490 }
451491
492+ /**
493+ * @return string Config environmentKey.
494+ */
495+ public function getEnvironmentKey ()
496+ {
497+ return $ this ->environmentKey ;
498+ }
499+
500+ /**
501+ * @return string Config sdkKey.
502+ */
503+ public function getSdkKey ()
504+ {
505+ return $ this ->sdkKey ;
506+ }
507+
452508 /**
453509 * @return array List of feature flags parsed from the datafile
454510 */
@@ -457,6 +513,38 @@ public function getFeatureFlags()
457513 return $ this ->_featureFlags ;
458514 }
459515
516+ /**
517+ * @return array List of attributes parsed from the datafile
518+ */
519+ public function getAttributes ()
520+ {
521+ return $ this ->attributes ;
522+ }
523+
524+ /**
525+ * @return array List of audiences parsed from the datafile
526+ */
527+ public function getAudiences ()
528+ {
529+ return $ this ->audiences ;
530+ }
531+
532+ /**
533+ * @return array List of events parsed from the datafile
534+ */
535+ public function getEvents ()
536+ {
537+ return $ this ->events ;
538+ }
539+
540+ /**
541+ * @return array List of typed audiences parsed from the datafile
542+ */
543+ public function getTypedAudiences ()
544+ {
545+ return $ this ->typedAudiences ;
546+ }
547+
460548 /**
461549 * @return array List of all experiments (including group experiments)
462550 * parsed from the datafile
@@ -470,7 +558,7 @@ public function getAllExperiments()
470558 $ rolloutExperimentIds [] = $ experiment ->getId ();
471559 }
472560 }
473- return array_filter (array_values ($ this ->_experimentKeyMap ), function ($ experiment ) use ($ rolloutExperimentIds ) {
561+ return array_filter (array_values ($ this ->_experimentIdMap ), function ($ experiment ) use ($ rolloutExperimentIds ) {
474562 return !in_array ($ experiment ->getId (), $ rolloutExperimentIds );
475563 });
476564 }
0 commit comments