Passed
Push — variadic-pattern ( b0f4a5...705257 )
by Martin
10:38
created

Unaccent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A customizeFunction() 0 3 1
A getNodeMappingPattern() 0 3 1
A validateArguments() 0 5 3
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 UNACCENT.
12
 *
13
 * @see https://www.postgresql.org/docs/17/unaccent.html
14
 *
15
 * @author Martin Hasoň <[email protected]>
16
 */
17
class Unaccent extends BaseVariadicFunction
18
{
19 2
    protected function getNodeMappingPattern(): array
20
    {
21 2
        return ['StringPrimary'];
22
    }
23
24 2
    protected function customizeFunction(): void
25
    {
26 2
        $this->setFunctionPrototype('unaccent(%s)');
27
    }
28
29 2
    protected function validateArguments(Node ...$arguments): void
30
    {
31 2
        $argumentCount = \count($arguments);
32 2
        if ($argumentCount < 1 || $argumentCount > 2) {
33 1
            throw InvalidArgumentForVariadicFunctionException::between('unaccent', 1, 2);
34
        }
35
    }
36
}
37