diff --git a/src/FeatureSwitch.php b/src/FeatureSwitch.php index 5e69384..199e6f5 100644 --- a/src/FeatureSwitch.php +++ b/src/FeatureSwitch.php @@ -38,7 +38,8 @@ public function addFeature(Feature\SwitchableFeatureInterface $feature) if (isset($this->features[$feature->getKey()])) { throw new \Exception(sprintf('There are already a feature with this key: %s', $feature->getKey())); } - $this->features[$feature->getKey()] = $feature; + + $this->storeFeature($feature); } /** @@ -53,4 +54,12 @@ public function isEnabled($key) } return $this->features[$key]->isEnabled(); } + + /** + * @param Feature\SwitchableFeatureInterface $feature + */ + protected function storeFeature(Feature\SwitchableFeatureInterface $feature) + { + $this->features[$feature->getKey()] = $feature; + } } \ No newline at end of file diff --git a/src/FeatureSwitchArray.php b/src/FeatureSwitchArray.php index 9f64e2a..daf950d 100644 --- a/src/FeatureSwitchArray.php +++ b/src/FeatureSwitchArray.php @@ -128,8 +128,7 @@ public function offsetSet($offset, $value) return; } - $this->features[$value->getKey()] = $value; - + $this->storeFeature($value); } /**