StringProperty::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 StringProperty
11
 * @package MisterIcy\ExcelWriter\Properties
12
 */
13
final class StringProperty extends AbstractProperty
14
{
15
    /**
16
     * StringProperty constructor.
17
     */
18
    public function __construct()
19
    {
20
        $this->formatCode = NumberFormat::FORMAT_TEXT;
21
    }
22
23
    /**
24
     * @param object $object
25
     * @return mixed|string
26
     * @throws PropertyException
27
     */
28
    public function renderProperty(object $object)
29
    {
30
        $rendered = parent::renderProperty($object);
31
        if (!$this->isFormula) {
32
            return strval($rendered);
33
        }
34
        return $rendered;
35
    }
36
}
37