Passed
Push — main ( 67265c...6a5ba9 )
by Martin
36:25 queued 21:26
created

ToTsvector::getNodeMappingPattern()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;
6
7
use Doctrine\ORM\Query\AST\Node;
8
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
9
10
/**
11
 * Implementation of PostgreSQL TO_TSVECTOR().
12
 *
13
 * @see https://www.postgresql.org/docs/9.4/static/textsearch-controls.html
14
 * @since 0.1
15
 *
16
 * @author Martin Georgiev <[email protected]>
17
 */
18
class ToTsvector extends BaseVariadicFunction
19
{
20 3
    protected function getNodeMappingPattern(): array
21
    {
22 3
        return ['StringExpression'];
23
    }
24
25 3
    protected function customizeFunction(): void
26
    {
27 3
        $this->setFunctionPrototype('to_tsvector(%s)');
28
    }
29
30 3
    protected function validateArguments(Node ...$arguments): void
31
    {
32 3
        $argumentCount = \count($arguments);
33 3
        if ($argumentCount < 1 || $argumentCount > 2) {
34 1
            throw InvalidArgumentForVariadicFunctionException::between('to_tsvector', 1, 2);
35
        }
36
    }
37
}
38