/** * @param $method * @param $args * * @return $this|mixed|null|object * @throws NotFound */ public function __call($method, $args) { if (isset($args[0]) && $args[0] instanceof AbstractObject) { $arg = $args[0]; } else { $arg = new AbstractObject(); $arg->setArgs($args); } $arrChains = []; foreach ($this->validators as $validator) { if ($validator->canHandle($method)) { $arrChains[] = $validator; } } if (!$arrChains) { throw new Exception('Method ' . $method . " doesn't exist in " . get_class($this) . " (AbstractGroupValidator::__call)"); } $result = chain($arrChains, $method, ['context' => $arg]); if ($result === true) { return $this; } return $result; }