PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Style / NumberFormat / Wizard / DateTime.php

DateTime.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php

51 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;
4
5 class DateTime extends DateTimeWizard
6 {
7 /**
8 * @var array<?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 \TablePress\PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\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 }
51