StringProperty   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 __construct() 0 3 1
A renderProperty() 0 7 2
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