/**
* Apply RuleSet on fixers to filter out all unwanted fixers.
*
* @param RuleSetInterface $ruleSet
*
* @return $this
*/
public function useRuleSet(RuleSetInterface $ruleSet)
{
$fixers = array();
$fixersByName = array();
foreach (array_keys($ruleSet->getRules()) as $name) {
if (!array_key_exists($name, $this->fixersByName)) {
throw new \UnexpectedValueException(sprintf('Rule "%s" does not exist.', $name));
}
$fixer = $this->fixersByName[$name];
$fixer->configure($ruleSet->getRuleConfiguration($name));
$fixers[] = $fixer;
$fixersByName[$name] = $fixer;
}
$this->fixers = $fixers;
$this->fixersByName = $fixersByName;
return $this;
}