Passed
Pull Request — master (#534)
by
unknown
02:44
created

Integer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 1
A getName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Rule;
6
7
use Attribute;
8
use Closure;
9
10
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
11
final class Integer extends AbstractNumber
12
{
13
    public function __construct(
14
        float|int|null $min = null,
15
        float|int|null $max = null,
16
        string $incorrectInputMessage = 'The allowed types are integer, float and string.',
17
        string $notNumberMessage = 'Value must be an integer.',
18
        string $tooSmallMessage = 'Value must be no less than {min}.',
19
        string $tooBigMessage = 'Value must be no greater than {max}.',
20
        string $pattern = '/^\s*[+-]?\d+\s*$/',
21
        mixed $skipOnEmpty = null,
22
        bool $skipOnError = false,
23
        Closure|null $when = null,
24
    ) {
25
        parent::__construct(
26
            min: $min,
27
            max: $max,
28
            incorrectInputMessage: $incorrectInputMessage,
29
            notNumberMessage: $notNumberMessage,
30
            tooSmallMessage: $tooSmallMessage,
31
            tooBigMessage: $tooBigMessage,
32
            pattern: $pattern,
33
            skipOnEmpty: $skipOnEmpty,
34
            skipOnError: $skipOnError,
35
            when: $when,
36
        );
37
    }
38
39
    public function getName(): string
40
    {
41
        return 'integer';
42
    }
43
}
44