Passed
Push — validate-arguments-for-variadi... ( 03b437 )
by Martin
03:26
created

Row   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A customizeFunction() 0 3 1
A validateArguments() 0 5 2
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 Row Constructor expression.
11
 *
12
 * @see https://www.postgresql.org/docs/14/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS
13
 */
14
class Row extends BaseVariadicFunction
15
{
16
    protected string $commonNodeMapping = 'InParameter';
17
18
    protected function customizeFunction(): void
19
    {
20
        $this->setFunctionPrototype('ROW(%s)');
21
    }
22
23
    protected function validateArguments(array $arguments): void
24
    {
25
        $argumentCount = \count($arguments);
26
        if ($argumentCount === 0) {
27
            throw InvalidArgumentForVariadicFunctionException::atLeast('ROW', 1);
28
        }
29
    }
30
}
31