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

RegexpLike   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getNodeMappingPattern() 0 7 1
A getMaxArgumentCount() 0 3 1
A getFunctionName() 0 3 1
A getMinArgumentCount() 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_LIKE().
9
 *
10
 * Returns true if a string matches a POSIX regular expression pattern, or false if it does not.
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_LIKE(e.text, 'pattern', 3, 'i') FROM Entity e"
18
 */
19
class RegexpLike 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_like';
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