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

InvalidArgumentForVariadicFunctionException   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A between() 0 7 1
A evenNumber() 0 5 1
A atLeast() 0 7 2
A exactCount() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception;
6
7
class InvalidArgumentForVariadicFunctionException extends \InvalidArgumentException
8
{
9
    public static function exactCount(string $functionName, int $expected): self
10
    {
11
        return new self(\sprintf(
12
            '%s() requires exactly %d argument%s',
13
            $functionName,
14
            $expected,
15
            $expected === 1 ? '' : 's'
16
        ));
17
    }
18
19
    public static function atLeast(string $functionName, int $min): self
20
    {
21
        return new self(\sprintf(
22
            '%s() requires at least %d argument%s',
23
            $functionName,
24
            $min,
25
            $min === 1 ? '' : 's'
26
        ));
27
    }
28
29
    public static function between(string $functionName, int $min, int $max): self
30
    {
31
        return new self(\sprintf(
32
            '%s() requires between %d and %d arguments',
33
            $functionName,
34
            $min,
35
            $max
36
        ));
37
    }
38
39
    public static function evenNumber(string $functionName): self
40
    {
41
        return new self(\sprintf(
42
            '%s() requires an even number of arguments',
43
            $functionName
44
        ));
45
    }
46
}
47