Passed
Push — array_agg-and-order_by ( 4a69e9 )
by Martin
03:10
created

ArrayAgg::customiseFunction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;
6
7
use Doctrine\ORM\Query\Parser;
8
use Doctrine\ORM\Query\SqlWalker;
9
10
/**
11
 * Implementation of PostgreSql ARRAY_AGG().
12
 *
13
 * @see https://www.postgresql.org/docs/17/functions-aggregate.html
14
 * @since 1.4
15
 *
16
 * @author Martin Georgiev <[email protected]>
17
 */
18
class ArrayAgg extends BaseOrderableFunction
19
{
20
    protected function customiseFunction(): void
21
    {
22
        $this->setFunctionPrototype('array_agg(%s%s)');
23
    }
24
25
    protected function parseFunction(Parser $parser): void
26
    {
27
        $this->expression = $parser->StringPrimary();
28
    }
29
30
    public function getSql(SqlWalker $sqlWalker): string
31
    {
32
        $dispatched = [
33
            $this->expression->dispatch($sqlWalker),
34
            $this->getOptionalOrderByClause($sqlWalker),
35
        ];
36
37
        return \vsprintf($this->functionPrototype, $dispatched);
38
    }
39
}
40