Issues (4)

src/Properties/DateTimeProperty.php (1 issue)

Labels
Severity
1
<?php
2
declare(strict_types=1);
3
4
namespace MisterIcy\ExcelWriter\Properties;
5
6
use MisterIcy\ExcelWriter\Exceptions\PropertyException;
7
use MisterIcy\ExcelWriter\Properties\Traits\DateTimeTrait;
8
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
9
10
/**
11
 * Class DateTimeProperty
12
 * @package MisterIcy\ExcelWriter\Properties
13
 */
14
final class DateTimeProperty extends AbstractProperty
15
{
16
    use DateTimeTrait;
17
18
    /**
19
     * DateTimeProperty constructor.
20
     */
21
    public function __construct()
22
    {
23
        $this->formatCode = NumberFormat::FORMAT_DATE_DATETIME;
24
    }
25
26
    /**
27
     * @param object $object
28
     * @return float|mixed
29
     * @throws PropertyException
30
     */
31
    public function renderProperty(object $object)
32
    {
33
        $rendered = parent::renderProperty($object);
34
        if (!$this->isFormula) {
35
            return (
36
                $this->convertDateTimeToExcelDateTime(
37
                    $rendered
0 ignored issues
show
It seems like $rendered can also be of type string; however, parameter $object of MisterIcy\ExcelWriter\Pr...teTimeToExcelDateTime() does only seem to accept DateTimeInterface|null, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
                    /** @scrutinizer ignore-type */ $rendered
Loading history...
38
                )
39
            );
40
        }
41
        return $rendered;
42
    }
43
}
44