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

Arr::validateArguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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