Passed
Push — chore ( a0ff7c )
by Martin
39:06 queued 26:08
created

Index   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMinArgumentCount() 0 3 1
A getFunctionName() 0 3 1
A getMaxArgumentCount() 0 3 1
A getNodeMappingPattern() 0 5 1
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 index function for ltree.
11
 *
12
 * Returns position of first occurrence of b in a, or -1 if not found.
13
 * The search starts at position offset; negative offset means start -offset labels from the end of the path.
14
 *
15
 * @see https://www.postgresql.org/docs/17/ltree.html#LTREE-FUNCTIONS
16
 * @since 3.5
17
 *
18
 * @author Martin Georgiev <[email protected]>
19
 *
20
 * @example Using it in DQL: "SELECT INDEX(e.path, 'Child1') FROM Entity e"
21
 * Returns integer, position of first occurrence or -1 if not found.
22
 */
23
class Index extends BaseVariadicFunction
24
{
25 3
    protected function getNodeMappingPattern(): array
26
    {
27 3
        return [
28 3
            'StringPrimary,StringPrimary,SimpleArithmeticExpression',
29 3
            'StringPrimary,StringPrimary',
30 3
        ];
31
    }
32
33 3
    protected function getFunctionName(): string
34
    {
35 3
        return 'index';
36
    }
37
38 3
    protected function getMinArgumentCount(): int
39
    {
40 3
        return 2;
41
    }
42
43 3
    protected function getMaxArgumentCount(): int
44
    {
45 3
        return 3;
46
    }
47
}
48