FloatProperty::renderProperty()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace MisterIcy\ExcelWriter\Properties;
5
6
use MisterIcy\ExcelWriter\Exceptions\PropertyException;
7
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
8
9
/**
10
 * Class FloatProperty
11
 * @package MisterIcy\ExcelWriter\Properties
12
 */
13
final class FloatProperty extends AbstractProperty
14
{
15
    /**
16
     * FloatProperty constructor.
17
     */
18
    public function __construct()
19
    {
20
        $this->formatCode = NumberFormat::FORMAT_NUMBER_00;
21
    }
22
23
    /**
24
     * @param object $object
25
     * @return float|mixed
26
     * @throws PropertyException
27
     */
28
    public function renderProperty(object $object)
29
    {
30
        $rendered = parent::renderProperty($object);
31
        if (!$this->isFormula) {
32
            return floatval($rendered);
33
        }
34
        return $rendered;
35
    }
36
}
37