private function validateQueryBuilderInitializer(\Closure $initializer)
    {
        $reflection = new \ReflectionFunction($initializer);
        $parameters = $reflection->getParameters();

        if (2 !== count($parameters)) {
            throw new InvalidArgumentException("The query builder initializer must have two and only two arguments.");
        }

        $class = $parameters[0]->getClass();
        if (!$class || $class->getName() !== QueryBuilder::class) {
            throw new InvalidArgumentException(sprintf(
                "The query builder initializer's first argument must be type hinted to the %s class.",
                QueryBuilder::class
            ));
        }

        if (!in_array($parameters[1]->getType(), [null, 'string'], true)) {
            throw new InvalidArgumentException(sprintf(
                "The query builder initializer's second must be type hinted to 'string'.",
                QueryBuilder::class
            ));
        }
    }
private function validateQueryBuilderInitializer(\Closure $initializer)
    {
        $reflection = new \ReflectionFunction($initializer);
        $parameters = $reflection->getParameters();

        if (2 !== count($parameters)) {
            throw new InvalidArgumentException("The query builder initializer must have two and only two arguments.");
        }

        $class = $parameters[0]->getClass();
        if (!$class || $class->getName() !== QueryBuilder::class) {
            throw new InvalidArgumentException(sprintf(
                "The query builder initializer's first argument must be type hinted to the %s class.",
                QueryBuilder::class
            ));
        }

        if (!in_array($parameters[1]->getType(), [null, 'string'], true)) {
            throw new InvalidArgumentException(sprintf(
                "The query builder initializer's second must be type hinted to 'string'.",
                QueryBuilder::class
            ));
        }
    }
private function validateQueryBuilderInitializer ( \ Closure $ initializer ) { $ reflection = new \ ReflectionFunction ( $ initializer ) ; $ parameters = $ reflection -> getParameters ( ) ; if ( 2 !== count ( $ parameters ) ) { throw new InvalidArgumentException ( "The query builder initializer must have two and only two arguments." ) ; } $ class = $ parameters [ 0 ] -> getClass ( ) ; if ( ! $ class || $ class -> getName ( ) !== QueryBuilder :: class ) { throw new InvalidArgumentException ( sprintf ( "The query builder initializer's first argument must be type hinted to the %s class." , QueryBuilder :: class ) ) ; } if ( ! in_array ( $ parameters [ 1 ] -> getType ( ) , [ null , 'string' ] , true ) ) { throw new InvalidArgumentException ( sprintf ( "The query builder initializer's second must be type hinted to 'string'." , QueryBuilder :: class ) ) ; } }
Validates the query builder initializer.

@param \Closure $initializer

@throws InvalidArgumentException
Validates the query builder initializer .