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

UnsignedInt   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 10 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