Test Failed
Push — renovate/major-composer-qa-too... ( 9595c4...d17b72 )
by
unknown
13:07
created

JsonbPathQueryArray::getNodeMappingPattern()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
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 JSONB_PATH_QUERY_ARRAY().
12
 *
13
 * Returns all JSON items returned by the JSON path for the specified JSON value as a JSON array.
14
 *
15
 * @see https://www.postgresql.org/docs/14/functions-json.html
16
 * @since 3.1
17
 *
18
 * @author Martin Georgiev <[email protected]>
19
 *
20
 * @example Using it in DQL: "SELECT JSONB_PATH_QUERY_ARRAY(e.jsonbData, '$.items[*].id') FROM Entity e"
21
 */
22
class JsonbPathQueryArray extends BaseVariadicFunction
23
{
24
    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\...ons\JsonbPathQueryArray.
Loading history...
25
26
    protected function getNodeMappingPattern(): array
27
    {
28
        return ['StringPrimary'];
29
    }
30
31
    protected function getFunctionName(): string
32
    {
33
        return 'jsonb_path_query_array';
34
    }
35
36
    protected function getMinArgumentCount(): int
37
    {
38
        return 2;
39
    }
40
41
    protected function getMaxArgumentCount(): int
42
    {
43
        return 4;
44
    }
45
46
    protected function validateArguments(Node ...$arguments): void
47
    {
48
        parent::validateArguments(...$arguments);
49
50
        // Validate that the fourth parameter is a valid boolean if provided
51
        if (\count($arguments) === 4) {
52
            $this->validateBoolean($arguments[3], $this->getFunctionName());
53
        }
54
    }
55
}
56