Passed
Push — ltree-functions ( d4a019 )
by Martin
13:48
created

Lca::getMaxArgumentCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Ltree;
6
7
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseVariadicFunction;
8
9
/**
10
 * Implementation of PostgreSQL lca function.
11
 *
12
 * Computes longest common ancestor of paths (up to 8 arguments are supported).
13
 * Also supports array input: lca(ltree[]).
14
 *
15
 * @see https://www.postgresql.org/docs/current/ltree.html#LTREE-FUNCTIONS
16
 * @since 3.5
17
 *
18
 * @author Martin Georgiev <[email protected]>
19
 *
20
 * @example Using it in DQL: "SELECT LCA(e.path1, e.path2) FROM Entity e"
21
 * Returns ltree, longest common ancestor of paths.
22
 */
23
class Lca extends BaseVariadicFunction
24
{
25 1
    protected function getNodeMappingPattern(): array
26
    {
27 1
        return ['StringPrimary'];
28
    }
29
30 1
    protected function getFunctionName(): string
31
    {
32 1
        return 'lca';
33
    }
34
35 1
    protected function getMinArgumentCount(): int
36
    {
37 1
        return 2;
38
    }
39
40 1
    protected function getMaxArgumentCount(): int
41
    {
42 1
        return 8;
43
    }
44
}
45