Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…everting minor bc-break (`attach` method should keep a compatible signature)
  • Loading branch information
Ocramius committed Nov 19, 2014
1 parent d570801 commit eeb8fb9
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/ValidatorChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,23 @@ public function plugin($name, array $options = null)
* If $breakChainOnFailure is true, then if the validator fails, the next validator in the chain,
* if one exists, will not be executed.
*
* @param callable|ValidatorInterface $callback A Validator implementation or valid PHP callback
* @param bool $breakChainOnFailure
* @param int $priority Priority at which to enqueue validator; defaults to
* @param ValidatorInterface $validator
* @param bool $breakChainOnFailure
* @param int $priority Priority at which to enqueue validator; defaults to
* 1 (higher executes earlier)
*
* @throws Exception\InvalidArgumentException
*
* @return self
*/
public function attach($callback, $breakChainOnFailure = false, $priority = self::DEFAULT_PRIORITY)
{
if (! ($callback instanceof ValidatorInterface || is_callable($callback))) {
throw new Exception\InvalidArgumentException(sprintf(
'Expected a valid PHP callable or Zend\Validator\ValidatorInterface; "%s" received',
is_object($callback) ? get_class($callback) : gettype($callback)
));
}

public function attach(
ValidatorInterface $validator,
$breakChainOnFailure = false,
$priority = self::DEFAULT_PRIORITY
) {
$this->validators->insert(
array(
'instance' => $callback,
'instance' => $validator,
'breakChainOnFailure' => (bool) $breakChainOnFailure,
),
$priority
Expand Down

0 comments on commit eeb8fb9

Please sign in to comment.