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

RegexpCount   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 24
ccs 12
cts 12
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMaxArgumentCount() 0 3 1
A getMinArgumentCount() 0 3 1
A getNodeMappingPattern() 0 6 1
A getFunctionName() 0 3 1
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