RelativeHumidity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 39
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromNative() 0 6 1
A __construct() 0 14 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