Passed
Push — variadic-array ( 86e6eb )
by Martin
03:19
created

Arr   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 14
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

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