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 / DateTimeWizard.php

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

52 lines 1.1 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 use Stringable;
6
7 abstract class DateTimeWizard implements Wizard
8 {
9 protected const NO_ESCAPING_NEEDED = "$+-/():!^&'~{}<>= ";
10
11 /**
12 * @param array<?string> $separators
13 *
14 * @return array<?string>
15 */
16 protected function padSeparatorArray(array $separators, int $count): array
17 {
18 $lastSeparator = (string) array_pop($separators);
19
20 return $separators + array_fill(0, $count, $lastSeparator);
21 }
22
23 protected function escapeSingleCharacter(string $value): string
24 {
25 if (str_contains(self::NO_ESCAPING_NEEDED, $value)) {
26 return $value;
27 }
28
29 return "\\{$value}";
30 }
31
32 protected function wrapLiteral(string $value): string
33 {
34 if (mb_strlen($value, 'UTF-8') === 1) {
35 return $this->escapeSingleCharacter($value);
36 }
37
38 // Wrap any other string literals in quotes, so that they're clearly defined as string literals
39 return '"' . str_replace('"', '""', $value) . '"';
40 }
41
42 protected function intersperse(string $formatBlock, ?string $separator): string
43 {
44 return "{$formatBlock}{$separator}";
45 }
46
47 public function __toString(): string
48 {
49 return $this->format();
50 }
51 }
52