UnsignedInt   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 7 2
1
<?php
2
3
namespace TraderInteractive\Filter;
4
5
use TraderInteractive\Exceptions\FilterException;
6
7
/**
8
 * A collection of filters for unsigned integers.
9
 */
10
final class UnsignedInt
11
{
12
    /**
13
     * Filters $value to an unsigned integer strictly.
14
     *
15
     * @see \TraderInteractive\Filter\Ints::filter()
16
     *
17
     * @param mixed $value     The value to be checked.
18
     * @param bool  $allowNull Indicates if the value can be null.
19
     * @param int   $minValue  Indicates the minimum acceptable value.
20
     * @param int   $maxValue  Indicates the maximum acceptable value.
21
     *
22
     * @return int|null
23
     *
24
     * @throws \InvalidArgumentException if minvalue is not greater or equal to zero.
25
     * @throws FilterException on failure to filter.
26
     */
27
    public static function filter($value, bool $allowNull = false, int $minValue = 0, int $maxValue = PHP_INT_MAX)
28
    {
29
        if ($minValue < 0) {
30
            throw new \InvalidArgumentException("{$minValue} was not greater or equal to zero");
31
        }
32
33
        return Ints::filter($value, $allowNull, $minValue, $maxValue);
34
    }
35
}
36