1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard; 4 5 class DateTime extends DateTimeWizard 6 { 7 /** 8 * @var string[] 9 */ 10 protected array $separators; 11 12 /** 13 * @var array<DateTimeWizard|string> 14 */ 15 protected array $formatBlocks; 16 17 /** 18 * @param null|string|string[] $separators 19 * If you want to use only a single format block, then pass a null as the separator argument 20 * @param DateTimeWizard|string ...$formatBlocks 21 */ 22 public function __construct($separators, ...$formatBlocks) 23 { 24 $this->separators = $this->padSeparatorArray( 25 is_array($separators) ? $separators : [$separators], 26 count($formatBlocks) - 1 27 ); 28 $this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks); 29 } 30 31 /** 32 * @param DateTimeWizard|string $value 33 */ 34 private function mapFormatBlocks($value): string 35 { 36 // Any date masking codes are returned as lower case values 37 if (is_object($value)) { 38 // We can't explicitly test for Stringable until PHP >= 8.0 39 return $value; 40 } 41 42 // Wrap any string literals in quotes, so that they're clearly defined as string literals 43 return $this->wrapLiteral($value); 44 } 45 46 public function format(): string 47 { 48 return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators)); 49 } 50 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body