Skip to content

Commit

Permalink
Remove code duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
systream committed Jun 5, 2016
1 parent 445fbab commit 9d64efc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/FeatureSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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;
}
}
3 changes: 1 addition & 2 deletions src/FeatureSwitchArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public function offsetSet($offset, $value)
return;
}

$this->features[$value->getKey()] = $value;

$this->storeFeature($value);
}

/**
Expand Down

0 comments on commit 9d64efc

Please sign in to comment.