public function condition($callback) : self
    {
        if ($this->inCondition) {
            throw new LogicException('Cannot nest rule conditions');
        }

        // Order is important here
        $this->createRule(ConditionalRule::class, [$callback]);
        $this->inCondition = true;

        return $this;
    }
public function condition($callback) : self
    {
        if ($this->inCondition) {
            throw new LogicException('Cannot nest rule conditions');
        }

        // Order is important here
        $this->createRule(ConditionalRule::class, [$callback]);
        $this->inCondition = true;

        return $this;
    }
public function condition ( $ callback ) : self { if ( $ this -> inCondition ) { throw new LogicException ( 'Cannot nest rule conditions' ) ; } // Order is important here $ this -> createRule ( ConditionalRule :: class , [ $ callback ] ) ; $ this -> inCondition = true ; return $ this ; }
Specifies conditions that must be met for certain rules to be set

@param callable $callback The callback to evaluate The variable list of rules
It must accept an array of all values
@return self For method chaining
@throws LogicException Thrown if we were already in a condition
Specifies conditions that must be met for certain rules to be set