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

ToTsquery::customizeFunction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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 TO_TSQUERY().
11
 *
12
 * @see https://www.postgresql.org/docs/9.4/static/textsearch-controls.html
13
 * @since 0.1
14
 *
15
 * @author Martin Georgiev <[email protected]>
16
 */
17
class ToTsquery extends BaseVariadicFunction
18
{
19
    protected function customizeFunction(): void
20
    {
21
        $this->setFunctionPrototype('to_tsquery(%s)');
22
    }
23
24
    protected function validateArguments(array $arguments): void
25
    {
26
        $argumentCount = \count($arguments);
27
        if ($argumentCount < 1 || $argumentCount > 2) {
28
            throw InvalidArgumentForVariadicFunctionException::between('to_tsquery', 1, 2);
29
        }
30
    }
31
}
32