IntProperty::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 IntProperty
11
 * @package MisterIcy\ExcelWriter\Properties
12
 */
13
final class IntProperty extends AbstractProperty
14
{
15
    /**
16
     * IntProperty constructor.
17
     */
18
    public function __construct()
19
    {
20
        $this->formatCode = NumberFormat::FORMAT_NUMBER;
21
    }
22
23
    /**
24
     * Renders a property and returns the value to be written.
25
     *
26
     * @param $object
27
     * @return mixed
28
     * @throws PropertyException
29
     */
30
    public function renderProperty(object $object)
31
    {
32
        $rendered = parent::renderProperty($object);
33
        if (!$this->isFormula) {
34
            return intval($rendered);
35
        }
36
        return $rendered;
37
    }
38
}
39