Passed
Push — variadic-pattern ( b0f4a5...705257 )
by Martin
10:38
created

Arr   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 17
ccs 7
cts 8
cp 0.875
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getNodeMappingPattern() 0 3 1
A validateArguments() 0 5 2
A customizeFunction() 0 3 1
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\Exception\InvalidArgumentForVariadicFunctionException;
9
10
/**
11
 * Implementation of PostgreSQL ARRAY[].
12
 *
13
 * @see https://www.postgresql.org/docs/9.4/static/arrays.html
14
 * @since 0.1
15
 *
16
 * @author Martin Georgiev <[email protected]>
17
 */
18
class Arr extends BaseVariadicFunction
19
{
20 6
    protected function getNodeMappingPattern(): array
21
    {
22 6
        return ['StringPrimary'];
23
    }
24
25 6
    protected function customizeFunction(): void
26
    {
27 6
        $this->setFunctionPrototype('ARRAY[%s]');
28
    }
29
30 6
    protected function validateArguments(Node ...$arguments): void
31
    {
32 6
        $argumentCount = \count($arguments);
33 6
        if ($argumentCount === 0) {
34
            throw InvalidArgumentForVariadicFunctionException::atLeast('ARRAY', 1);
35
        }
36
    }
37
}
38