Passed
Push — main ( ef688d...18ec90 )
by Martin
14:11
created

RegexpMatch   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMaxArgumentCount() 0 3 1
A getMinArgumentCount() 0 3 1
A getNodeMappingPattern() 0 4 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_MATCH().
9
 *
10
 * Returns the first substring(s) that match a POSIX regular expression pattern, or NULL if there is no match.
11
 *
12
 * @see https://www.postgresql.org/docs/17/functions-matching.html#FUNCTIONS-POSIX-REGEXP
13
 * @since 2.0
14
 *
15
 * @author Martin Georgiev <[email protected]>
16
 *
17
 * @example Using it in DQL: "SELECT REGEXP_MATCH(e.text, 'pattern', 'i') FROM Entity e"
18
 */
19
class RegexpMatch extends BaseVariadicFunction
20
{
21 3
    protected function getNodeMappingPattern(): array
22
    {
23 3
        return [
24 3
            'StringPrimary',
25 3
        ];
26
    }
27
28 3
    protected function getFunctionName(): string
29
    {
30 3
        return 'regexp_match';
31
    }
32
33 3
    protected function getMinArgumentCount(): int
34
    {
35 3
        return 2;
36
    }
37
38 3
    protected function getMaxArgumentCount(): int
39
    {
40 3
        return 3;
41
    }
42
}
43