Failed Conditions
Pull Request — master (#75)
by
unknown
03:37
created

UnsignedInt::filter()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 3
nop 4
1
<?php
2
3
namespace TraderInteractive\Filter;
4
5
use TraderInteractive\Filter\Ints;
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
     * @throws \InvalidArgumentException if $minValue was not greater or equal to zero
18
     */
19
    public static function filter($value, $allowNull = false, $minValue = null, $maxValue = PHP_INT_MAX)
20
    {
21
        if ($minValue === null) {
22
            $minValue = 0;
23
        } elseif (is_int($minValue) && $minValue < 0) {
24
            throw new \InvalidArgumentException("{$minValue} was not greater or equal to zero");
25
        }
26
27
        return Ints::filter($value, $allowNull, $minValue, $maxValue);
28
    }
29
}
30