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

Unaccent::validateArguments()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 5
rs 10
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 UNACCENT.
11
 *
12
 * @see http://www.postgresql.org/docs/current/static/unaccent.html
13
 *
14
 * @author Martin Hasoň <[email protected]>
15
 */
16
class Unaccent extends BaseVariadicFunction
17
{
18
    protected string $commonNodeMapping = 'StringPrimary';
19
20
    protected function customizeFunction(): void
21
    {
22
        $this->setFunctionPrototype('unaccent(%s)');
23
    }
24
25
    protected function validateArguments(array $arguments): void
26
    {
27
        $argumentCount = \count($arguments);
28
        if ($argumentCount < 1 || $argumentCount > 2) {
29
            throw InvalidArgumentForVariadicFunctionException::between('unaccent', 1, 2);
30
        }
31
    }
32
}
33