Passed
Push — drop-flagged ( ada556 )
by Martin
18:51 queued 03:27
created

RegexpMatch::getMinArgumentCount()   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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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', 3, 'i') FROM Entity e"
18
 */
19
class RegexpMatch 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,StringPrimary',
27 3
            'StringPrimary,StringPrimary',
28 3
        ];
29
    }
30
31 3
    protected function getFunctionName(): string
32
    {
33 3
        return 'regexp_match';
34
    }
35
36 3
    protected function getMinArgumentCount(): int
37
    {
38 3
        return 2;
39
    }
40
41 3
    protected function getMaxArgumentCount(): int
42
    {
43 3
        return 4;
44
    }
45
}
46