Jyxo\Input\Fluent::condition PHP Метод

condition() публичный Метод

If there are conditions in the current chain, adds the condition as a subchain.
public condition ( string $name, mixed $param = null ) : self
$name string Validator name
$param mixed Additional validator parameter
Результат self
    public function condition(string $name, $param = null) : self
    {
        $condChain = new Chain\Conditional($this->factory->getValidatorByName($name, $param));
        if (true === $this->chain->isEmpty()) {
            // The actual chain is empty, can be replaced by the condition
            $this->chain = $condChain;
            if (null === $this->currentName) {
                throw new \BadMethodCallException('No active variable');
            }
            $this->chains[$this->currentName] = $condChain;
        } else {
            $this->chain = $this->chain->addCondition($condChain);
        }
        return $this;
    }