UnsignedInt   A
last analyzed

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
 * Defines the DominionEnterprises\Filter\UnsignedInt class.
4
 */
5
6
namespace DominionEnterprises\Filter;
7
8
use DominionEnterprises\Filter\Ints;
9
10
/**
11
 * A collection of filters for unsigned integers.
12
 */
13
final class UnsignedInt
14
{
15
    /**
16
     * Filters $value to an unsigned integer strictly.
17
     *
18
     * @see \DominionEnterprises\Filter\Ints::filter()
19
     *
20
     * @throws \InvalidArgumentException if $minValue was not greater or equal to zero
21
     */
22
    public static function filter($value, $allowNull = false, $minValue = null, $maxValue = PHP_INT_MAX)
23
    {
24
        if ($minValue === null) {
25
            $minValue = 0;
26
        } elseif (is_int($minValue) && $minValue < 0) {
27
            throw new \InvalidArgumentException("{$minValue} was not greater or equal to zero");
28
        }
29
30
        return Ints::filter($value, $allowNull, $minValue, $maxValue);
31
    }
32
}
33