IntProperty   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderProperty() 0 7 2
A __construct() 0 3 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