Issues (4)

src/Properties/DateProperty.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 DateProperty
12
 * @package MisterIcy\ExcelWriter\Properties
13
 */
14
final class DateProperty extends AbstractProperty
15
{
16
    use DateTimeTrait;
17
18
    /**
19
     * DateProperty constructor.
20
     */
21
    public function __construct()
22
    {
23
        $this->formatCode = NumberFormat::FORMAT_DATE_DDMMYYYY;
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
35
        if (!$this->isFormula) {
36
            return (
37
                $this->convertDateTimeToExcelDate(
38
                    $rendered
0 ignored issues
show
It seems like $rendered can also be of type string; however, parameter $object of MisterIcy\ExcelWriter\Pr...rtDateTimeToExcelDate() 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

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