Add a new check to the set

@param string $name Function name
@param string $type Check type
@param array $args Check arguments
@throws \InvalidArgumentException If check type is invalid
760379
protected function addCheck($name, $type, $args)
    {
        $func = $type.'Check';

        if (method_exists($this, $func)) {
            $type = strtolower(str_replace($type, '', $name));
            $this->$func($type, $name, $args);
        } else {
          throw new \InvalidArgumentException('Invalid check type: '.$type);
        }
    }
452801
public function addRuleCallback($name, Callable $callback)
    {
        if (!is_string($name)) {
            throw new \InvalidArgumentException('Rule must be a string');
        }

        $rule = $this->createRuleCallback($name, $callback);
        $this->addRule($rule);
    }
828779
public function addPlugin($name, array $args)
    {
        $plugin = ['class' => $name, 'args' => $args];
        $this->config[$this->pointer][$this->field]['type'] = $plugin;
        
        return $this;
    }
82494
public function setFieldType($name, $type)
    {
        $this->checkFieldExist($name)->types[$name] = $type;

        return $this;
    }
122672
protected function createRule(string $className, array $args = [])
    {
        if (!class_exists($className)) {
            throw new InvalidArgumentException("Class \"$className\" does not exist");
        }

        /** @var IRule|IRuleWithArgs $rule */
        $rule = new $className;

        if ($rule instanceof IRuleWithArgs) {
            $rule->setArgs($args);
        }

        $this->addRule($rule);
    }
823648
private function createQuestion(string $name, int $type): Question
    {
        if (0 > $type || 0xffff < $type) {
            $message = \sprintf('%d does not correspond to a valid record type (must be between 0 and 65535).', $type);
            throw new \Error($message);
        }

        $question = $this->questionFactory->create($type);
        $question->setName($name);

        return $question;
    }
945160
public function setType($type)
    {
        if (gettype($type) === 'string') {
            $this->type = $type;
        } else {
            $msg = "Type must be a string, '" . gettype($type) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
1184511
public function addModifier($name, $callback)
    {
        if (!is_callable($callback)) {
            throw new InvalidArgumentException('Invalid argument type. Callbacks must be callable.');
        }
        $this->modifiers[$name] = $callback;
        return $this;
    }
769738
protected function _setQuery(string $type, $args): self
    {
        if (!\is_array($args) && !($args instanceof AbstractSpanQuery)) {
            throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractSpanQuery');
        }

        return $this->setParam($type, $args);
    }
1243733
public function add( $name, $type = Type::TEXT, $rules = [] ) {
		$this->fields[$name] = new Field($name, $type, $rules);
		$this->types = [];	// clear this so it will be refreshed when we've finished adding fields
		return $this;
	}
35565
protected function resolve($type, $name, $registry, array $args = array())
    {
        if($registry instanceof \Closure)
            return call_user_func_array($registry->bindTo($this), $args);

        if(is_string($registry)) {
            if($type == 'service')
                return $this->instantiate($registry);
            else
                return $this->instantiate($registry, $args);
        }

        // assume index 0 as class name
        if(is_array($registry))
        {
            $class = $registry[0];

            $arguments = array();

            // argument passed
            if(isset($registry[1]))
            {
                // the second element isn't an array
                if(!is_array($registry[1]))
                    throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Second value for array based ['.$name.'] registry must be an array');

                foreach($registry[1] as $arg)
                {
                    // if isn't string. allow only string.
                    if(!is_string($arg))
                        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Argument for array based ['.$name.'] registry must be string');

                    if($arg = $this->tokenResolve($arg))
                        $arguments[] = $arg;
                }
            }

            // merge with the one passed
            $arguments = array_merge($arguments, $args);

            return $this->instantiate($class, $arguments);
        }

        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Unable to resolve the ['.$name.'] registry');
    }
140521
public function addFunctionPostCallFunction($type, $name, callable $function)
    {

        $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){
            $this->fnPostCallFunctions[$type][$name][] = $function;
        }, function($target) use ( $function, $name){
            $this->addFunctionPostCallFunction($target, $name, $function);
        });

    }
1317254
private function setClass( $name, $args ) {

		// Build the class string dynamically.
		$class = __NAMESPACE__ . '\\Notice\\' . ucfirst( $name );

		// Create a new instance or add our filters.
		return $this->class = class_exists( $class ) ? new $class( $args ) : Filter::add( $this );
	}
1289262
public function addParam($name, $type = null)
    {
        $this->params[(string)$name] = $type;
        return $this;
    }
103580
public function validate($args)
    {
        $matched = false;

        //validates arguments
        foreach ($args as $arg => $value) {
            //non-named option are skipped from validation
            if (is_numeric($arg)) continue;
            //validates action options
            foreach ($this->options as $option) {
                //checks if options matches specified parameter
                if ($option->matchParam($arg)) {
                    //validates option
                    if (!$option->validate($value)) {
                        throw new InvalidArgumentException($arg, $value);
                    }
                    $matched = true;
                }
            }
            if (!$matched) {
                throw new InvalidOptionException($arg);
            }
        }
        //validates required options
        foreach ($this->options as $option) {
            if (!$option->isRequired()) {
                continue;
            }

            if (!$option->getValue($args)) {
                throw new MissingRequiredArgumentException($option->getName());
            }
        }

        return true;
    }
1097424
protected function setType(string $type) : void
    {
        if (empty($type)) {
            throw new InvalidArgumentException(__CLASS__ . ': Empty field type is not allowed');
        }

        if (! in_array($type, array_keys($this->defaultOptions))) {
            throw new InvalidArgumentException(__CLASS__ . ': Unsupported field type: ' . $type);
        }

        $this->type = $type;
    }
304951
public function addCallback(string $name, $callback)
    {
        if (!is_object($callback)) {
            throw new \InvalidArgumentException('Given callback must be an object');
        }

        $this->callbacks[$name] = $callback;
    }