DecimalValue::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 13/11/2016
5
 * Time: 13:26
6
 */
7
8
namespace Del\Common\Value;
9
10
use InvalidArgumentException;
11
12
class DecimalValue extends AbstractValue
13
{
14
    /**
15
     * IntValue constructor.
16
     *
17
     * @param float $value
18
     */
19 2
    public function __construct($value)
20
    {
21 2
        if(!is_numeric($value)) {
22 1
            throw new InvalidArgumentException('Please supply a numeric value');
23
        }
24 2
        $this->value = (float) number_format((float) $value, 2,'.','');
25 2
    }
26
27
    /**
28
     * @return float
29
     */
30 1
    public function getValue()
31
    {
32 1
        return parent::getValue();
33
    }
34
}