Passed
Push — main ( f99623...118bfa )
by Martin
30:43 queued 15:46
created

JsonStripNulls::getNodeMappingPattern()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
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\BooleanValidationTrait;
9
10
/**
11
 * Implementation of PostgreSQL JSON_STRIP_NULLS().
12
 *
13
 * Supports optional second parameter (PostgreSQL 18+) to control null stripping from arrays.
14
 *
15
 * @see https://www.postgresql.org/docs/18/functions-json.html
16
 * @since 0.10
17
 *
18
 * @author Martin Georgiev <[email protected]>
19
 */
20
class JsonStripNulls extends BaseVariadicFunction
21
{
22
    use BooleanValidationTrait;
0 ignored issues
show
Bug introduced by
The trait MartinGeorgiev\Doctrine\...\BooleanValidationTrait requires the property $value which is not provided by MartinGeorgiev\Doctrine\...unctions\JsonStripNulls.
Loading history...
23
24 1
    protected function getFunctionName(): string
25
    {
26 1
        return 'json_strip_nulls';
27
    }
28
29 1
    protected function getNodeMappingPattern(): array
30
    {
31 1
        return [
32 1
            'StringPrimary',
33 1
        ];
34
    }
35
36 1
    protected function getMinArgumentCount(): int
37
    {
38 1
        return 1;
39
    }
40
41 1
    protected function getMaxArgumentCount(): int
42
    {
43 1
        return 2;
44
    }
45
46 1
    protected function validateArguments(Node ...$arguments): void
47
    {
48 1
        parent::validateArguments(...$arguments);
49
50 1
        if (\count($arguments) === 2) {
51 1
            $this->validateBoolean($arguments[1], $this->getFunctionName());
52
        }
53
    }
54
}
55