Passed
Push — regex ( 45e535 )
by Martin
12:24
created

RegexpCount   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 getMaxArgumentCount() 0 3 1
A getMinArgumentCount() 0 3 1
A getNodeMappingPattern() 0 5 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') 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',
26 3
        ];
27
    }
28
29 3
    protected function getFunctionName(): string
30
    {
31 3
        return 'regexp_count';
32
    }
33
34 3
    protected function getMinArgumentCount(): int
35
    {
36 3
        return 2;
37
    }
38
39 3
    protected function getMaxArgumentCount(): int
40
    {
41 3
        return 4;
42
    }
43
}
44