/** * {@inheritdoc} */ public function set($key, $regex) { $regex = (string) $regex; if ('' !== $regex) { // Remove first (^) and last ($) regex pattern. $regex = preg_replace('/^\\^(.*)\\$$/', '$1', $regex); } return parent::set($key, $regex); }
/** * Expands a flattened array to a new ParameterBag . * * @param array $flat * * @return ParameterBag **/ public static function expand(array $flat) { $bag = new ParameterBag(); foreach ($flat as $key => $value) { $bag->set($key, $value); } return $bag; }