RelativeHumidity::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
3
namespace ValueObjects\Climate;
4
5
use ValueObjects\Number\Natural;
6
use ValueObjects\Exception\InvalidNativeArgumentException;
7
8
class RelativeHumidity extends Natural
9
{
10
    const MIN = 0;
11
12
    const MAX = 100;
13
14
    /**
15
     * Returns a new RelativeHumidity from native int value
16
     *
17
     * @param int $value
0 ignored issues
show
Bug introduced by
There is no parameter named $value. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
18
     * @return RelativeHumidity
19
     */
20 1
    public static function fromNative()
21
    {
22 1
        $value = func_get_arg(0);
23
24 1
        return new static($value);
25
    }
26
27
    /**
28
     * Returns a new RelativeHumidity object
29
     *
30
     * @param int $value
31
     */
32 2
    public function __construct($value)
33
    {
34
        $options = array(
35 2
            'options' => array('min_range' => self::MIN, 'max_range' => self::MAX)
36 2
        );
37
38 2
        $filteredValue = filter_var($value, FILTER_VALIDATE_INT, $options);
39
40 2
        if (false === $filteredValue) {
41 1
            throw new InvalidNativeArgumentException($value, array('int (>=' . self::MIN . ', <=' . self::MAX . ')'));
42
        }
43
44 1
        parent::__construct($filteredValue);
45 1
    }
46
}
47