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

atLeast()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
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