Natural   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

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