Passed
Push — main ( d2ee47...5e6956 )
by Martin
36:33 queued 21:32
created

MakeTimestamptz::getNodeMappingPattern()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;
6
7
use Doctrine\ORM\Query\AST\Node;
8
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Traits\TimezoneValidationTrait;
9
10
/**
11
 * Implementation of PostgreSQL MAKE_TIMESTAMPTZ().
12
 *
13
 * @see https://www.postgresql.org/docs/17/functions-datetime.html
14
 * @since 4.1
15
 *
16
 * @author Martin Georgiev <[email protected]>
17
 *
18
 * @example Using it in DQL: "SELECT MAKE_TIMESTAMPTZ(2023, 6, 15, 10, 30, 0, 'UTC') FROM Entity e"
19
 */
20
class MakeTimestamptz extends BaseVariadicFunction
21
{
22
    use TimezoneValidationTrait;
0 ignored issues
show
Bug introduced by
The trait MartinGeorgiev\Doctrine\...TimezoneValidationTrait requires the property $value which is not provided by MartinGeorgiev\Doctrine\...nctions\MakeTimestamptz.
Loading history...
23
24 6
    protected function getNodeMappingPattern(): array
25
    {
26 6
        return [
27 6
            'ArithmeticPrimary,ArithmeticPrimary,ArithmeticPrimary,ArithmeticPrimary,ArithmeticPrimary,ArithmeticPrimary,StringPrimary',
28 6
            'ArithmeticPrimary',
29 6
        ];
30
    }
31
32 6
    protected function getFunctionName(): string
33
    {
34 6
        return 'make_timestamptz';
35
    }
36
37 6
    protected function getMinArgumentCount(): int
38
    {
39 6
        return 6;
40
    }
41
42 6
    protected function getMaxArgumentCount(): int
43
    {
44 6
        return 7;
45
    }
46
47 6
    protected function validateArguments(Node ...$arguments): void
48
    {
49 6
        parent::validateArguments(...$arguments);
50
51 6
        if (\count($arguments) === 7) {
52 6
            $this->validateTimezone($arguments[6], $this->getFunctionName());
53
        }
54
    }
55
}
56