/** * Convert a rule string into a chain * * @param string $ruleString Chain Rules string format * * @return Chain */ public function convert($ruleString) { $ruleSet = json_decode($ruleString); $this->_throwExceptionOnInvalidRuleSet($ruleSet); $rules = []; foreach ($ruleSet as $rule) { $ruleClass = $rule->rule; $settings = (array) $rule->settings; $this->_throwExceptionOnUnknownRuleClass($ruleClass); $rules[] = new $ruleClass($settings); } $chain = new Chain(); $chain->setRules($rules); return $chain; }