Passed
Push — main ( 5be9c9...995947 )
by Martin
14:57
created

RegexpCount::getFunctionName()   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;
6
7
/**
8
 * Implementation of PostgreSQL REGEXP_COUNT().
9
 *
10
 * Returns the number of times the POSIX regular expression pattern matches in the string.
11
 *
12
 * @see https://www.postgresql.org/docs/15/functions-matching.html#FUNCTIONS-POSIX-REGEXP
13
 * @since 3.1
14
 *
15
 * @author Martin Georgiev <[email protected]>
16
 *
17
 * @example Using it in DQL: "SELECT REGEXP_COUNT(e.text, '\d\d\d', 1, 'i') FROM Entity e"
18
 */
19
class RegexpCount extends BaseVariadicFunction
20
{
21 3
    protected function getNodeMappingPattern(): array
22
    {
23 3
        return [
24 3
            'StringPrimary,StringPrimary,ArithmeticPrimary,StringPrimary',
25 3
            'StringPrimary,StringPrimary,ArithmeticPrimary',
26 3
            'StringPrimary,StringPrimary',
27 3
        ];
28
    }
29
30 3
    protected function getFunctionName(): string
31
    {
32 3
        return 'regexp_count';
33
    }
34
35 3
    protected function getMinArgumentCount(): int
36
    {
37 3
        return 2;
38
    }
39
40 3
    protected function getMaxArgumentCount(): int
41
    {
42 3
        return 4;
43
    }
44
}
45