-
Notifications
You must be signed in to change notification settings - Fork 30
feat: datafile accessor #211
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
Changes from all commits
4828321
a500260
6030dec
0e0246e
63e1cca
c44287c
764e40b
043d852
1363d51
ae01873
8f78fcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,11 @@ class DatafileProjectConfig implements ProjectConfigInterface | |
*/ | ||
private $_botFiltering; | ||
|
||
/** | ||
* @var string datafile. | ||
*/ | ||
private $datafile; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the privacy convention has changed. I think @oakbani had showed me that previously. See: https://www.php-fig.org/psr/psr-12/#43-properties-and-constants |
||
|
||
/** | ||
* @var string Revision of the datafile. | ||
*/ | ||
|
@@ -196,6 +201,7 @@ public function __construct($datafile, $logger, $errorHandler) | |
{ | ||
$supportedVersions = array(self::V2, self::V3, self::V4); | ||
$config = json_decode($datafile, true); | ||
$this->datafile = $datafile; | ||
$this->_logger = $logger; | ||
$this->_errorHandler = $errorHandler; | ||
$this->_version = $config['version']; | ||
|
@@ -355,6 +361,14 @@ public static function createProjectConfigFromDatafile($datafile, $skipJsonValid | |
return $config; | ||
} | ||
|
||
/** | ||
* @return string String representing contents of datafile. | ||
*/ | ||
public function toDatafile() | ||
{ | ||
return $this->datafile; | ||
} | ||
|
||
/** | ||
* @return string String representing account ID from the datafile. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,11 +37,18 @@ class OptimizelyConfig implements \JsonSerializable | |
*/ | ||
private $featuresMap; | ||
|
||
public function __construct($revision, array $experimentsMap, array $featuresMap) | ||
/** | ||
* @var string Contents of datafile. | ||
*/ | ||
private $datafile; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
public function __construct($revision, array $experimentsMap, array $featuresMap, $datafile = null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do not provide a default null for datafile. |
||
{ | ||
$this->revision = $revision; | ||
$this->experimentsMap = $experimentsMap; | ||
$this->featuresMap = $featuresMap; | ||
$this->datafile = $datafile; | ||
} | ||
|
||
/** | ||
|
@@ -52,6 +59,14 @@ public function getRevision() | |
return $this->revision; | ||
} | ||
|
||
/** | ||
* @return string Datafile contents. | ||
*/ | ||
public function getDatafile() | ||
{ | ||
return $this->datafile; | ||
} | ||
|
||
/** | ||
* @return array Map of Experiment Keys to OptimizelyExperiments. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,8 @@ public function testOptimizelyConfigEntity() | |
$expectedJson = '{ | ||
"revision": "20", | ||
"experimentsMap" : {"a": "apple"}, | ||
"featuresMap": {"o": "orange"} | ||
"featuresMap": {"o": "orange"}, | ||
"datafile": null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. |
||
}'; | ||
|
||
$expectedJson = json_encode(json_decode($expectedJson)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be $_datafile?