|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright 2020, Optimizely Inc and Contributors |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +namespace Optimizely\OptimizelyConfig; |
| 18 | + |
| 19 | +class OptimizelyConfig implements \JsonSerializable |
| 20 | +{ |
| 21 | + /** |
| 22 | + * @var string Revision of the config. |
| 23 | + */ |
| 24 | + private $revision; |
| 25 | + |
| 26 | + /** |
| 27 | + * Map of Experiment Keys to OptimizelyExperiments. |
| 28 | + * |
| 29 | + * @var <String, OptimizelyExperiment> associative array |
| 30 | + */ |
| 31 | + private $experimentsMap; |
| 32 | + |
| 33 | + /** |
| 34 | + * Map of Feature Keys to OptimizelyFeatures. |
| 35 | + * |
| 36 | + * @var <String, OptimizelyFeature> associative array |
| 37 | + */ |
| 38 | + private $featuresMap; |
| 39 | + |
| 40 | + public function __construct($revision, array $experimentsMap, array $featuresMap) |
| 41 | + { |
| 42 | + $this->revision = $revision; |
| 43 | + $this->experimentsMap = $experimentsMap; |
| 44 | + $this->featuresMap = $featuresMap; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @return string Config revision. |
| 49 | + */ |
| 50 | + public function getRevision() |
| 51 | + { |
| 52 | + return $this->revision; |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * @return array Map of Experiment Keys to OptimizelyExperiments. |
| 57 | + */ |
| 58 | + public function getExperimentsMap() |
| 59 | + { |
| 60 | + return $this->experimentsMap; |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * @return array Map of Feature Keys to OptimizelyFeatures. |
| 65 | + */ |
| 66 | + public function getFeaturesMap() |
| 67 | + { |
| 68 | + return $this->featuresMap; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * @return string JSON representation of the object. |
| 73 | + */ |
| 74 | + public function jsonSerialize() |
| 75 | + { |
| 76 | + return get_object_vars($this); |
| 77 | + } |
| 78 | +} |
0 commit comments