Natural::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
3
namespace ValueObjects\Number;
4
5
use ValueObjects\Exception\InvalidNativeArgumentException;
6
7
class Natural extends Integer
8
{
9
    /**
10
     * Returns a Natural object given a PHP native int as parameter.
11
     *
12
     * @param int $value
13
     */
14 85
    public function __construct($value)
15
    {
16
        $options = array(
17
            'options' => array(
18
                'min_range' => 0
19 85
            )
20 85
        );
21
22 85
        $filteredValue = filter_var($value, FILTER_VALIDATE_INT, $options);
23
24 85
        if (false === $filteredValue) {
25 2
            throw new InvalidNativeArgumentException($value, array('int (>=0)'));
26
        }
27
28 83
        parent::__construct($filteredValue);
29 83
    }
30
}
31