/**
  * @inheritdoc
  */
 public function onFinish(ErrorAggregatorInterface $aggregator)
 {
     $errorsBeforeFirst = count($aggregator->get());
     $this->first->onFinish($aggregator);
     $errorsAfterFirst = count($aggregator->get());
     if ($errorsAfterFirst === $errorsBeforeFirst) {
         $this->second->onFinish($aggregator);
     }
 }
 /**
  * @param RuleInterface            $rule
  * @param mixed                    $input
  * @param ErrorAggregatorInterface $aggregator
  *
  * @return Generator
  */
 protected static function validateData(RuleInterface $rule, $input, ErrorAggregatorInterface $aggregator)
 {
     foreach ($rule->validate($input) as $error) {
         (yield $error);
     }
     $rule->onFinish($aggregator);
     foreach ($aggregator->get() as $error) {
         (yield $error);
     }
 }
 /**
  * @inheritdoc
  */
 public function onFinish(ErrorAggregatorInterface $aggregator)
 {
     // same logic here. We can think of the rule as failed only if both rules fail.
     // If both rules fail we issue errors only from 'primary' rule.
     $emptyAggregator = new ErrorAggregator();
     $this->secondary->onFinish($emptyAggregator);
     if (empty($emptyAggregator->get()) === false) {
         $this->primary->onFinish($aggregator);
     }
 }
 /**
  * @param array         $rules
  * @param RuleInterface $unlisted
  */
 public function __construct(array $rules, RuleInterface $unlisted)
 {
     parent::__construct($rules);
     $this->unlisted = $unlisted;
     $this->unlisted->setParentRule($this);
 }
 /**
  * @inheritdoc
  */
 public function onFinish(ErrorAggregatorInterface $aggregator)
 {
     if ($this->selectedRule !== null) {
         $this->selectedRule->onFinish($aggregator);
     }
 }
 /**
  * @param RuleInterface $rule
  */
 public function __construct(RuleInterface $rule)
 {
     $rule->setParentRule($this);
     $this->rule = $rule;
 }