Passed
Push — master ( a287b0...451f7a )
by Aleksandr
02:07
created

Assert   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A integer() 0 6 2
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Aleksandr Drobotik <[email protected]>
5
 * @copyright 2023 Aleksandr Drobotik
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Drobotik\Eav\Validation;
11
12
use Symfony\Component\Validator\Constraints;
13
class Assert
14
{
15
    public static function integer(): Constraints\IsTrue
16
    {
17
        return new Constraints\IsTrue([
18
            'message' => 'Should be an integer',
19
            'payload' => function ($value) {
20
                return is_numeric($value) && (int)$value == $value;
21
            }
22
        ]);
23
    }
24
}