protected function appendRule(Validatable $validator) { if (!$validator->getName() && $this->getName()) { $validator->setName($this->getName()); } $this->rules[spl_object_hash($validator)] = $validator; }
/** * Creates a new instance of the RespectValidationAdapter class. * * @param string $name * @param Validatable $validator * * @throws InvalidArgumentException */ public function __construct($name, Validatable $validator) { if (!is_string($name)) { throw new InvalidArgumentException('`$name` parameter must be a string.'); } $validator->setName($name); $this->validator = $validator; }
public function __construct($reference, Validatable $validator = null, $mandatory = true) { $this->setName($reference); if ($validator && !$validator->getName()) { $validator->setName($reference); } $this->reference = $reference; $this->validator = $validator; $this->mandatory = $mandatory; }