Pinq\Tests\Integration\Providers\DSL\Implementation\English\QueryCompilation::appendFunction PHP Method

appendFunction() public method

public appendFunction ( Pinq\Queries\Functions\IFunction $function )
$function Pinq\Queries\Functions\IFunction
    public function appendFunction(IFunction $function)
    {
        if ($function->isInternal()) {
            throw new Exception('Internal functions are not supported');
        }
        $this->append('{');
        if ($function->countBodyExpressions() === 0) {
            $this->append('}');
        } elseif ($function->countBodyExpressions() === 1) {
            $this->append(' ');
            $this->append($function->getBodyExpressions()[0]->compile() . ';');
            $this->append(' }');
        } else {
            $this->appendLine();
            $this->append(implode(';' . PHP_EOL, Expression::compileAll($function->getBodyExpressions())) . ';');
            $this->appendLine();
            $this->append('}');
        }
        $parameterMap = $function->getParameterScopedVariableMap();
        if (!empty($parameterMap)) {
            $this->append(' with parameters: [');
            $parameters = [];
            foreach ($parameterMap as $variableName) {
                $parameters[] = "\${$variableName}";
            }
            $this->append(implode(', ', $parameters));
            $this->append(']');
        }
    }

Usage Example

Ejemplo n.º 1
0
 protected function appendOptionalProjection($string, Requests\ProjectionRequestBase $request)
 {
     $this->compilation->append($string);
     if ($request->hasProjectionFunction()) {
         $this->compilation->append(' according to the function: ');
         $this->compilation->appendFunction($request->getProjectionFunction());
     }
 }
All Usage Examples Of Pinq\Tests\Integration\Providers\DSL\Implementation\English\QueryCompilation::appendFunction