/** * Offset to set * @link http://php.net/manual/en/arrayaccess.offsetset.php * @param mixed $offset <p> * The offset to assign the value to. * </p> * @param SwitchableFeatureInterface $value <p> * The value to set. * </p> * @throws \Exception * @since 5.0.0 */ public function offsetSet($offset, $value) { if (!$value instanceof SwitchableFeatureInterface) { throw new \Exception('The value must be SwitchableFeatureInterface'); } if (!is_null($offset)) { if ($offset != $value->getKey()) { throw new \Exception('The given key and the feature key are not the same.'); } $this->features[$offset] = $value; return; } $this->storeFeature($value); }
/** * @param Feature\SwitchableFeatureInterface $feature */ protected function storeFeature(Feature\SwitchableFeatureInterface $feature) { $this->features[$feature->getKey()] = $feature; }