/** * Convert the chain into its JSON counter part * * @param Chain $chain Chain object to stringify * * @return string */ public function stringify($chain) { $ruleSet = []; $rules = $chain->getRules(); /** @var Rule $rule */ foreach ($rules as $rule) { $ruleSet[] = ["rule" => get_class($rule), "settings" => $rule->getSettings()]; } return json_encode($ruleSet); }