MisterIcy /
excel-writer
| 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
Bug
introduced
by
Loading history...
|
|||
| 39 | ) |
||
| 40 | ); |
||
| 41 | } |
||
| 42 | return $rendered; |
||
| 43 | } |
||
| 44 | } |
||
| 45 |