CurrencyProperty   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 22
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 PhpOffice\PhpSpreadsheet\Style\NumberFormat;
7
8
/**
9
 * Class CurrencyProperty
10
 * @package MisterIcy\ExcelWriter\Properties
11
 */
12
final class CurrencyProperty extends AbstractProperty
13
{
14
    /**
15
     * CurrencyProperty constructor.
16
     */
17
    public function __construct()
18
    {
19
        $this->formatCode = NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE;
20
    }
21
22
    /**
23
     * @param object $object
24
     * @return float|mixed
25
     * @throws \MisterIcy\ExcelWriter\Exceptions\PropertyException
26
     */
27
    public function renderProperty(object $object)
28
    {
29
        $rendered = parent::renderProperty($object);
30
        if (!$this->isFormula) {
31
            return floatval($rendered);
32
        }
33
        return $rendered;
34
    }
35
}
36